Even after modifing the allocation of memory it was segementing.
Let me explain my problem:
I have tried to create a sample application only for reading the data from the /proc/stat file and plotting the cpudata values with respact to the timefactor.
The application was working fine till yesterday. But from yesterday what I have I have observed is the apllication is segmenting after 30-32 timerevents(total timer events are 12

. It was segementing while trying to open the /proc/stat file .
Following is the snippet of the segmentation message :
/**********************************************************************************/
*** glibc detected *** ./cpu: malloc(): memory corruption: 0x0000000000669a40 *** ======= Backtrace: ========= /lib64/libc.so.6[0x36c4c6f0e4] /lib64/libc.so.6(__libc_malloc+0x7d)[0x36c4c7086d]
/lib64/libc.so.6[0x36c4c5ecda]
./cpu(_ZN7QWidget11qt_propertyEiiP8QVariant+0xef4)[0x4059ac]
/usr/lib64/qt-3.3/lib/libqt-mt.so.3(_ZN7QObject5eventEP6QEvent+0x66)[0x3e79560ff6]
/usr/lib64/qt-3.3/lib/libqt-mt.so.3(_ZN7QWidget5eventEP6QEvent+0x2

[0x3e79598518]
/usr/lib64/qt-3.3/lib/libqt-mt.so.3(_ZN12QApplication14internalNotifyEP7QObjectP6QEvent+0x85)[0x3e795007d5]
/usr/lib64/qt-3.3/lib/libqt-mt.so.3(_ZN12QApplication6notifyEP7QObjectP6QEvent+0xa4)[0x3e79501ca4]
/usr/lib64/qt-3.3/lib/libqt-mt.so.3(_ZN10QEventLoop14activateTimersEv+0x21c)[0x3e794f5bbc]
/usr/lib64/qt-3.3/lib/libqt-mt.so.3(_ZN10QEventLoop13processEventsEj+0x4e1)[0x3e794af351]
/usr/lib64/qt-3.3/lib/libqt-mt.so.3(_ZN10QEventLoop9enterLoopEv+0x41)[0x3e79517f91]
/usr/lib64/qt-3.3/lib/libqt-mt.so.3(_ZN10QEventLoop4execEv+0x22)[0x3e79517e72]
./cpu(_ZN7QWidget5closeEb+0x24b)[0x405523]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x36c4c1da44]
./cpu(_ZN7QWidget5closeEb+0xc1)[0x405399]
======= Memory map: ========
00400000-00407000 r-xp 00000000 08:03 622657 /DEMO/cpu/cpu
00607000-00608000 rw-p 00007000 08:03 622657 /DEMO/cpu/cpu
00608000-006aa000 rw-p 00608000 00:00 0 [heap]
36c4800000-36c481a000 r-xp 00000000 08:03 98887 /lib64/ld-2.5.so
36c4a19000-36c4a1a000 r--p 00019000 08:03 98887 /lib64/ld-2.5.so
/************************************************************************************************************************/
I have tried to find out why it was segmenting at the fopen call using strace, what I could find out is, the application is trying to open dev/tty/ file and segementing
Segmentation Message Sniipet:
/***********************************************************************************************************************************************/
write(1, "ThE TIMER event is called:\n", 27ThE TIMER event is called:
) = 27
write(1, "Before the fopen call:\n", 23Before the fopen call:
) = 23
open("/dev/tty", O_RDWR|O_NOCTTY|O_NONBLOCK) = 6 writev(6, [{"*** glibc detected *** ", 23}, {"./cpu", 5}, {": ", 2}, {"malloc(): memory corruption", 27}, {": 0x", 4}, {"0000000000673750", 16}, {" ***\n", 5}], 7*** glibc detected *** ./cpu: malloc(): memory corruption: 0x0000000000673750 ***
) = 82
mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2aaaae558000
munmap(0x2aaaae558000, 27951104) = 0
munmap(0x2aaab4000000, 39157760) = 0
mprotect(0x2aaab0000000, 135168, PROT_READ|PROT_WRITE) = 0 futex(0x36c4f4bf20, FUTEX_WAKE, 2147483647) = 0 futex(0x36d440cdd0, FUTEX_WAKE, 2147483647) = 0 write(6, "======= Backtrace: =========\n", 29======= Backtrace: =========
) = 29
writev(6, [{"/lib64/libc.so.6", 16}, {"[0x", 3}, {"36c4c6f0e4", 10}, {"]\n", 2}], 4/lib64/libc.so.6[0x36c4c6f0e4] /**************************************************************************************************************************************************/