-
Notifications
You must be signed in to change notification settings - Fork 51
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
Replace backtrace
crate with stabilized std::backtrace
implementation
#186
Conversation
I'm not comfortable having the stack trace collection of this crate be dependent on a rust specific environment variable. This is a feature of this crate and should thus be controlled by us / users of this crate directly from code. |
20ff10c
to
c1ed54e
Compare
@Jasper-Bekkers the comment exactly explains that that is the reason that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you for this proper migration to Rust's backtrace. I'll definitely celebrate having slightly fewer dependencies in my apps :)
…tion Rust 1.65 [stabilized `std::backtrace::Backtrace`], which we can use in place of the `backtrace` crate to reduce our dependency stack. Normally `Backtrace::capture()` would listen to the `RUST_BACKTRACE` and `RUST_LIB_BACKTRACE` environment variables, but this is unsuitable for us as capturing backtraces is configured via boolean debug feature flags in the `AllocatorDebugSettings` struct. Fortunately `Backtrace::force_capture()` exists which circumvents these env var checks and always returns a backtrace, and is hence used in the codebase here. Unfortuantely the type no longer implements `Clone` like `backtrace::Backtrace`, requiring us to wrap it in an `Arc` (because most of our types are thread-safe) to clone the `Backtrace` around various (sub)allocations and statistics reports. [stabilized `std::backtrace::Backtrace`]: https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#stabilized-apis
ceffaa6
to
5255af8
Compare
5255af8
to
66a96d9
Compare
Sticking to my promise of updating and submitting this old branch in #183.
Fixes #183 (by no longer using the
backrace
/cc
crate);Fixes #184 (the old approach from that branch).
Rust 1.65 stabilized
std::backtrace::Backtrace
, which we can use in place of thebacktrace
crate to reduce our dependency stack.Normally
Backtrace::capture()
would listen to theRUST_BACKTRACE
andRUST_LIB_BACKTRACE
environment variables, but this is unsuitable for us as capturing backtraces is configured via boolean debug feature flags in theAllocatorDebugSettings
struct. FortunatelyBacktrace::force_capture()
exists which circumvents these env var checks and always returns a backtrace, and is hence used in the codebase here.Unfortuantely the type no longer implements
Clone
likebacktrace::Backtrace
, requiring us to wrap it in anArc
(because most of our types are thread-safe) to clone theBacktrace
around various (sub)allocations and statistics reports.