Skip to content
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

Provide a non-empty error callback to libbacktrace #290

Closed
Aaron1011 opened this issue Feb 15, 2020 · 4 comments · Fixed by #423
Closed

Provide a non-empty error callback to libbacktrace #290

Aaron1011 opened this issue Feb 15, 2020 · 4 comments · Fixed by #423

Comments

@Aaron1011
Copy link
Member

Currently, the error callback function passed to libbacktrace does nothing:

extern "C" fn error_cb(_data: *mut c_void, _msg: *const c_char, _errnum: c_int) {
// do nothing for now
}

Doing something here (printing an error, or just setting a flag that makes backtrace-rs calls fail) will make it much easier to debug issues like rust-lang/rust#69151 - it took me quite a while to realize that the memory corruption I was seeing was the result of libbacktrace intentionally freeing memory.

@Aaron1011
Copy link
Member Author

It will be difficult to propagate any error that we catch, since functions like backtrace::resolve don't use Result.

@alexcrichton: What do you think about making backtrace::resolve take an FnMut(Result<&Symbol, SomeError>), or return an Result<(), SomeError>? It would make this library somewhat less ergonomic, but it would reflect the fact that some functions are not actually infallible.

@alexcrichton
Copy link
Member

It's currently intentional that this library pretty aggresively ignores errors. Almost all usages of this are related to debugging where an error parsing dwarf or something like that shouldn't take down other tasks.

I'm open to the idea of exposing errors somehow but I haven't really thought about how it would be done or what it would look like. There's a lot of platforms and implementations to consider here, and I'm not sure if we can usefully and efficiently communicate errors for all the platforms.

@Aaron1011
Copy link
Member Author

I think communicating the existence of an error (even it's a ZST on some platforms) would be an enormous improvement over reporting nothing at all. This would make it much easier to debug issues like rust-lang/rust#69151, since we'll know that something went wrong in libbacktrace itself.

@alexcrichton
Copy link
Member

Er I don't mean to sound like I'm challenging the assumption that this is useful, only that implementing it "fully" may be quite difficult. Having a simple boolean bit would likely be much easier to implement and could be done relatively easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants