The problem is that some piece of C level code is using a pointer that is pointing where it shouldn't. Therefore it is overwriting some other memory. When you try to use that other memory, something that should be impossible (generally a segfault) happens.
The trouble with this kind of bug is that the place where it shows up has nothing to do with where the bug really is. The bug could be in any C code, anywhere. The second problem is that anything that changes the internal memory layout of your program (eg adding print or warn statements to the file) will change what memory gets overwritten by the stray pointer and it apparently goes away. In fact the second characteristic is an indicator that this is the type of bug you are facing.
To fix it you either must track down the bug, or you must change the memory layout so that it doesn't seem to be biting you. The latter is easy - add some code until it doesn't seem to be a problem and pray. It is also unreliable. The former can be hard. Really hard. The best solution is a detailed code audit of all C code involved. I would suggest with the C libraries that you load because they are likely the least tested piece. This is sufficiently difficult that people have written tools to automate this process. Valgrind has been mentioned. More specialized tools like Coverity may be more appropriate (if more expensive).
However you tackle the problem, good luck.
In reply to Re: disappearing segfault
by tilly
in thread disappearing segfault
by cfreeman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |