Why sometimes stacktraces are printed and sometimes not?

wjoe invalid at example.com
Thu Sep 30 09:54:14 UTC 2021


On Wednesday, 29 September 2021 at 12:15:30 UTC, Steven 
Schveighoffer wrote:
> On 9/29/21 6:57 AM, JN wrote:
>> What makes the difference on whether a crash stacktrace gets 
>> printed or not?
>> 
>> Sometimes I get a nice clean stacktrace with line numbers, 
>> sometimes all I get is "segmentation fault error -1265436346" 
>> (pseudo example) and I need to run under debugger to get the 
>> crash location.
>
> segmentation faults are memory access errors. It means you are 
> accessing a memory address that is not valid for your 
> application. If you are accessing the wrong memory, it means 
> something is terribly wrong in your program.
>
> [...]

So on Linux, I don't know the behavior on other OSs, the kernel 
sends SIGSEGV to your process which, if unhandled, simply 
terminates your program.
It's an abnormal termination and thus the D runtime or whatever 
library that in a normal case takes care of printing the traces 
doesn't get a chance to do so anymore.

You also change the signal in your handler to get a core dump, 
look here 
http://www.alexonlinux.com/how-to-handle-sigsegv-but-also-generate-core-dump



More information about the Digitalmars-d-learn mailing list