dtolnay / dtolnay/anyhow

Reconsider stracktrace configurability with rust 2024 set_var changes.

Open
#403 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
6.7k
Forks
224
PR merge metrics
No merged PRs in 30d

Description

I know there has already been a lot of discussion on this, so my apologies for bringing it up again, but rust 2024 will change the original context this decision may have been made in.

Previously I raised https://github.com/dtolnay/anyhow/issues/342 but then I found a workaround to disable anyhow backtrace capturing via:
```rust
if std::env::var("RUST_LIB_BACKTRACE").is_err() {
std::env::set_var("RUST_LIB_BACKTRACE", "0");
}
```
This resolved my issue and the issue was closed.

However, with rust 2024, [set_var will be marked unsafe](https://doc.rust-lang.org/nightly/edition-guide/rust-2024/newly-unsafe-functions.html).
Many high level codebases have a blanket ban on unsafe, so even if `set_var` can be soundly called at the start of the application before any threads are created, there is no way to create a sound wrapper API for that as it could still be called after that point.
So this approach is not usable in codebases with a blanket ban on unsafe.

Does this alter the original assumptions around the decision to "not expose a way for the application to configure whether stacktraces are captured"?
If this changes nothing go ahead and close the issue.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.