Known reasons why D crashes without any message?

qznc via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 14 13:41:01 PDT 2017


On Wednesday, 13 September 2017 at 10:20:48 UTC, Thorsten Sommer 
wrote:
> Right now, we are done with the development and ready to start 
> experiments. Until now, almost anything runs fine with our unit 
> tests.
>
> Besides the unit tests, the main program is now able to startup 
> but crashes after a while without any message at all. No stack 
> trace, no exception, nothing. Obviously, this makes it hard to 
> debug anything...

I assume you see a return code which is nonzero, because you say 
it "crashes". Which one?

Most likely would be a segmentation fault (invalid memory access, 
stack overflow, null pointer dereferenced, etc). Use a debugger. 
Compile with debug info and execute wrapped in gdb. It should 
stop right where it crashes and can show you a stack trace. If 
necessary, inspect the value of variables.

If gdb does not stop on its own, someone is calling exit to 
terminate prematurely. Set a breakpoint at exit to get a stack 
trace.

If you cannot use gdb on your server and you cannot trigger the 
crash on your desktop, maybe you can let it coredump on the 
server? Then use gdb to inspect the dump.

Did you try to annotate your code with @safe? It helps to avoid 
errors leading to segmentation faults.



More information about the Digitalmars-d mailing list