Ruby – Segmentation fault
Today I had a really nasty Ruby error, that bugged me quite a while.
I wanted to extract parts of an XML file and insert them into another one using the libxml-ruby gem. From time to time I got the following segementation fault error.
[BUG] Segmentation fault ruby 1.8.7 (2008-05-31 patchlevel 0) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
I tracked down the place in my code, where it happened, but could not really explain why it did. I tried to rewrite my code several times, always with the same result. The only thing that helped in the end, was to make sure that the Ruby garbage collector was running with
GC.enable and to start it with
GC.start after each XML file was processed.
What bugs me most, is the fact that I am not sure, what the real problem is. Otherwise I could write a bug report to ruby or libxml.