[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gerbv crashes (was Re: gEDA-user: gerbv 1.0 on RH8)



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Am 04.02.2005 um 22:12 schrieb Stefan Petersen:

Hello again!

According to your gdb dump it segfaults in a function called 'update_statusbar' when calling 'gtk_label_set_text' in gtk.

This can not happen, it is impossible. At least not where gdb dump shows. Broken gtk/glib/libc?

This can easily happen. The program segaults in calloc(), which is a malloc() like function. Due to thw way malloc() works, segfaults can occur (without the lib being broken) if the user program does things like writing past the end of malloc()ed buffers, writing to free()ed buffers or even free()in stuff, that isn'tn malloc()ed anymore (double calls to free()).


The Bugs often are miles away from the location, that segfaults. To find bugs like this one, you have to use a specual malloc()/free()-debugger like efence (Electric Fence). This is not a program (like gdb) but a library itself, which supplies malloc(), free() &co. efence is build in a special way, that common errors in using malloc()ed memory do not crash malloc()/fre()/... but let your program crash where the bug is located.

You have to link efence to your program, there even is a shared lib, which can be loaded using

	LD_PRELOAD=/path/to/libefence.so /some/program

efence checks for double free()s, delevers memory in a way, that accesses past the buffer end do segfault, and after free()in some memory, the address never gets used again, so accesses to free()ed memory segfault, too. OTOH, memory allocation with efence is much slower and long running programs can easily run out of memory. So only use it for debugging, not for production software.

73, Mario
- -- Mario Klebsch mario@xxxxxxxxxx
PGP-Key available at http://www.klebsch.de/public.key
Fingerprint DSS: EE7C DBCC D9C8 5DC1 D4DB 1483 30CE 9FB2 A047 9CE0
Diffie-Hellman: D447 4ED6 8A10 2C65 C5E5 8B98 9464 53FF 9382 F518
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)


iD8DBQFCBFv/MM6fsqBHnOARAu8rAJwPIOwfU5raBAQcwTF5OqwXWVMNfQCgoEjU
XX8nBn9rmtD30ej5LDaw0hw=
=ZdpB
-----END PGP SIGNATURE-----