December 02, 2012
On Sunday, December 02, 2012 10:14:16 d coder wrote:
> Greetings
> 
> I have a code that crashes with current github dmd snapshot with a segfault. It compiles and runs fine with the released versions of DMD. I am using lots of structs and classes in the code and I believe the problem could be related with the other issues that are there with structs. When I give the compiled binary to valgrind, the report suggests that the segfault might be related to garbage collector. I wanted to isolate the issue and report it on bugzilla. Can somebody help me with the valgrind trace below here, and guide me where to look for the problem? My actual code is thousands of lines big and I am at a loss as to how I should isolate and report this issue.
> 
> Regards
> - Puneet
> 
> ==4453== Invalid read of size 8
> ==4453==    at 0x44EFF5: _D4nett5mule5Mule3esl6__dtorMFZv
> (../src/nett/mule.d:115)
> ==4453==    by 0x471124: _D4nett5mule5Mule9EslDomain11__fieldDtorMFZv
> (../src/nett/mule.d:7923)
> ==4453==    by 0x4AD845: rt_finalize2 (in
> /home/pgoel/mule/examples/test_code)
> ==4453==    by 0x4ABC92: _D2gc3gcx3Gcx11fullcollectMFZm (in
> /home/pgoel/mule/examples/test_code)
> ==4453==    by 0x4A9BBA: _D2gc3gcx2GC18fullCollectNoStackMFZv (in
> /home/pgoel/mule/examples/test_code)
> ==4453==    by 0x4A7F2C: gc_term (in /home/pgoel/mule/examples/test_code)
> ==4453==    by 0x48661B: _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi6runAllMFZv
> (in /home/pgoel/mule/examples/test_code)
> ==4453==    by 0x4860F5:
> _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi7tryExecMFMDFZvZv (in
> /home/pgoel/mule/examples/test_code)
> ==4453==    by 0x4860B1: _d_run_main (in
> /home/pgoel/mule/examples/test_code)
> ==4453==    by 0x485EF2: main (in /home/pgoel/mule/examples/test_code)
> ==4453==  Address 0x2c0 is not stack'd, malloc'd or (recently) free'd

Did you at least use gdb to figure out where the segfault is occuring? If you compile with -gc, then dmd should produce the proper debug symbols for gdb, allowing you to use gdb with D programmers (though support for things like strings isn't very good - then again, C++ support in gdb is pretty poor too). You need at least gdb 7.2 IIRC, but since the current version is something like 7.5, that probably won't be  problem.

- Jonathan M Davis