Skip to content

Stack unwinding for the masses #2275

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

Closed
wants to merge 5 commits into from

Conversation

LemonBoy
Copy link
Contributor

TLDR

Backtraces are now fully functional in release mode! 🎉

Since the stack-walking strategy is not that reliable and since libunwind is always (? or most of the times? I didn't figure out that yet) linked in anyway why not use it?

This brief weekend project is my first attempt at writing some Zig code so please bear with me if the code is not that nice.

You may ask why I didn't roll my own unwinder... well I've got halfway trough (the whole eh_frame was perfectly parsed and all the opcodes executed) when all of a sudden I've realized that using libunwind would've been a better use of my time.

At the moment it's only been enabled for linux but should work pretty well on Apple's systems and/or BSDs, YMMV of course.

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is undeniably useful.

However, I think that relying on libunwind is a local maximum. (I realized that it's not always clear exactly what I mean by that, which is this).

The problem is that, although zig ships with libunwind for the purposes of cross compiling, for some targets, libunwind is provided by the system, not by Zig. That means we don't control the implementation, and we don't control these important factors:

Even for the implementation of libunwind that zig ships, it's just vendored code from upstream. I would like to avoid forking it. That means either way, we don't really control the implementation.

Ultimately, I think it will be worth it to have a competing implementation of stack unwinding, because it will allow us the flexibility to support these situations that require tight control over the implementation.

@LemonBoy
Copy link
Contributor Author

Ultimately, I think it will be worth it to have a competing implementation of stack unwinding, because it will allow us the flexibility to support these situations that require tight control over the implementation.

Yeah, I already have some code ready along with other niceties such as cross-library DWARF parsing that I'm slowly but steadily working on (and is blocked by #2354).

@LemonBoy LemonBoy closed this Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants