-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backtrace through signal handlers on alpine #698
Comments
Please describe exactly how you built the code. Exactly which rustc, installed from where, using what build configuration? |
Here is a dockerfile using a recent alpine.
Then you can copy the example I mentioned above, build it. (nothing special here)
And then I had to run it preloading libgcc_s. Somehow the build script was not linking libgcc_s.
If I understand well, both use libunwind. What version / distribution of libunwind is packaged into backtrace-rs? |
This was also visible on older alpine versions, using
|
I wonder if the difference could be induced by the fact that libunwind is pulled from ubuntu. |
What does |
So I had to split the examples as I had mixed C unwinding with libunwind along with backtrace-rs unwinding. New examples are here. With the new setup, we have separate binaries that have backtrace unwinding on one side:
libunwind is statically linked, but I still get a dynamic link to libgcc. And I compile the C unwinding by dynamically linking to libunwind (I had to adjust the build script in the example above, un-commenting the lines that do the linking to libunwind):
As mentioned previously, using libunwind manually, I'm able to get to the main from the crash (even if the symbols are not great)
|
Why are you trying to link against libunwind manually when rustc already links your program against libgcc_s? libunwind and libgcc_s are both exporting the same |
So I think I confused you with my setup.
|
At DataDog/libdatadog@474b67b#diff-ffb20d4b2b21cbbfd14872f5b864628343f71b89b55817525c08fad31ea3ae13R28-R29 you seem to try linking against both libunwind and libgcc_s. However I just saw that at DataDog/libdatadog@474b67b#diff-ffb20d4b2b21cbbfd14872f5b864628343f71b89b55817525c08fad31ea3ae13R21 you are reading |
So the unwind_c was essentially to try and investigate the issue. You can remove the build.rs (and everything else that relates to the C reproducer) to focus on the example with
And for the backtrace example, we do not need the linker logics to apply:
libunwind requires libgcc_s from what I noticed building the C example. |
I think this issue explains the unwinding failure and has a good example using std functions. |
So the summary of the issue is that:
Does all of this sound reasonable ? |
Using the context from the signal handler is indeed the correct solution. I get correct unwinding (obviously without the signal frames).
I'll leave the example if this is of interest. |
Description
While using the
backtrace::resolve_frame_unsynchronized
API it seems we are not going through signal handlers.Here is what I get when using the API,
As you can see I get stuck on sigwaitinfo and to not go up to the main function.
I wrote a small comparison to libunwind where I successfully unwind through the signal handler and get to the main function.
The issue could be within the miri API. I did not dive into what was done within this function.
Reproducer
Here is the source code for my example. I ran this on an alpine image where I made an install of libunwind. It might be difficult to run. Please reach out if you want more precise instructions.
Thanks for considering 🙇
The text was updated successfully, but these errors were encountered: