-
Notifications
You must be signed in to change notification settings - Fork 251
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
Filter frames by __rust_end_short_backtrace and __rust_begin_short_backtrace #502
Comments
I would prefer if this crate does not try to be clever about stack traces and instead leaves this up to the user of the library. In particular due to the fact that the top of the stack requires different handling with regards to the instruction addr compared to all other frames makes it for some cases important to understand if the stack has been truncated or not. |
Backtrace-rs already filters itself away, so the top of the printed backtrace is not the top of the actual stack. Also the libstd api allows you to choose if anything should be filtered or not. |
Surely it could just be something that can be toggled by the user? (and not impact existing users) Also, something that came up while @Gankra and I were discussing such functionality: what if not just the filtering, but That way, nothing would be hardcoding implementation details of anything else, and the |
I was considering proposing adding some alternatives to Backtrace::frames. Specifically:
These APIs should exist because without them people don't know how to properly use this library and are shipping broken things like just using a hardcoded |
tbc I'm happy to implement this if it will be accepted. until then i'm just going to implement the same logic in the above libraries to fix the ecosystem |
Also I couldn't find any such API in std::backtrace? Are you just referring to env vars? |
I've created the backtrace-ext crate with a short_frames_strict function as described above. miette now uses it. |
rustc inserts frames
std::sys_common::backtrace::__rust_end_short_backtrace
andstd::sys_common::backtrace::__rust_begin_short_backtrace
so that the internal backtrace implementation can filter out noise from backtrace capturing.Can we make use of these in the backtrace crate in order to have equivalent noise removal?
I'm not sure if these frame names are stable but I figure that we can just fall back to the old filtering implementation if they are missing?
Edit:
Oh huh, I just realized even std::backtrace::Backtrace isnt filtering these out... I filed an issue for it here: rust-lang/rust#105413
Example:
With the following program:
Currently the backtrace looks like this:
With filtering it would look like:
We could keep the full unfiltered version available via "{:#?}" formatting.
The text was updated successfully, but these errors were encountered: