Peculiar and weird problem in C
I have made an UDP server in C (Ubuntu 10.10). The server is quite large. When the server runs for the first time, it processes the data from the client correctly. But when another client comes along and sends some data, the program crashes with the following message:
Code:
MappingServer: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted
Now, I tried to use Valgrind to detect the problem. I used:
Code:
valgrind --leak-check=yes -v ./MappingServer
When I run the program like this, I have no more error (No matter how many clients!). What’s going on here? As far as I can understand, Valgrind is a debugging tool, it’s not suppose to fix anything, rather show me what’s wrong. Please someone explain. Also tell me about the original error message, what does it mean? Why does it crop up?