Why sometimes stacktraces are printed and sometimes not?
Steven Schveighoffer
schveiguy at gmail.com
Wed Sep 29 12:15:30 UTC 2021
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.
Note that on Windows in 32-bit mode, I believe you get a stack trace. On
Linux, there is the undocumented `etc.linux.memoryhandler` which allows
you to register an error-throwing signal handler.
Signals are not really easy to deal with in terms of properly throwing
an exception. This only works on Linux, so I don't know if it's possible
to port to other OSes. I've also found sometimes that it doesn't work
right, so I only enable it when I am debugging.
-Steve
More information about the Digitalmars-d-learn
mailing list