Fix missing stacktraces when using -d:useNimRtl #6716
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using
-d:useNimRtl, stack traces are useless ("No stack traceback available").This can be verified when compiling this example program in addition to
libnimrtl.so:Compile with
nim c -d:useNimRtl test_segfault.nimandnim c -o:libnimrtl.so nim-repo/lib/nimrtl.nim.Start (on linux) with
LD_LIBRARY_PATH=/path/to/libnimrtl.so ./test_segfaultThis happens because two instances of
framePtrexist at the same time: one fromlibnimrtl.so, and one from the test program (I ended up seeing this whenprintfing my way around and checking the generated c files). There is also twosignalHandlerpresent, the one from test_segfault is the one that runs last, apparently.The right
framePtrfromlibnimrtl.sois updated correctly bynimFrameand other functions, however when for example a segfault happens, the signalHandler from the test program runs, which refer to a nilframePtr.That
framePtrdoesn't contain any information on frames, thus why no stack traceback were available.This change ensure that there is only one signalHander that will be registered, the one from
libnimrtl.so, this should also avoid pulling a second nilframePtrby the test program.The stack traces should now be available and shown when using
useNimRtl.