Hello. I have the following problem. Everything wen fine, and all of the sudden, the program began crashing (with segmentation fault)
this is what gdb complains about
Code:
*** glibc detected *** malloc(): memory corruption: 0x0805b3a8 ***
Program received signal SIGABRT, Aborted.
[Switching to Thread 16384 (LWP 794)]
0x401adc81 in kill () from /lib/libc.so.6
(gdb) bt
#0 0x401adc81 in kill () from /lib/libc.so.6
#1 0x400274a1 in pthread_kill () from /lib/libpthread.so.0
#2 0x4002787b in raise () from /lib/libpthread.so.0
#3 0x401ad8f8 in raise () from /lib/libc.so.6
#4 0x401aef00 in abort () from /lib/libc.so.6
#5 0x401e16ce in __libc_message () from /lib/libc.so.6
#6 0x401e8781 in _int_malloc () from /lib/libc.so.6
#7 0x401ea2f1 in malloc () from /lib/libc.so.6
#8 0x401d8912 in fdopen@@GLIBC_2.1 () from /lib/libc.so.6
#9 0x0804c609 in client (this=0x805b338, _sock=8, _pin=
{sin_family = 2, sin_port = 60164, sin_addr = {s_addr = 83994816}, sin_zero = "\000\000\000\000\000\000\000"}) at client.cpp:28
#10 0x08049760 in main (argc=1, argv=0xbffff794) at main.cpp:101
(gdb) quit
client.cpp:28
Code:
this->rx=fdopen(_sock,"r");
I double checked, and _sock is greater than 0 and so on (you can see right from the output, here _sock=8). Can you please tell me what I am doing wrong? What really bugs me is that it doesn't consistently crash, but only at times. And after linking it with -lefence it stopped crashing:| . Now I removed the -lefence and it doesn't crash anymore. Don't know what to say.. Should I leave the -lefence?