rust-lang / rust-lang/backtrace-rs
Printing backtrace will leak PDB file handles
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 628
- Forks
- 291
- PR merge metrics
- No merged PRs in 30d
Description
backtrace-rs uses StackWalkEx on Windows, which calls SymLoadModuleEx in turn. The symbol modules are never unloaded afterward, keeping the PDB files open until the process exits.
Normally this wouldn't be an issue, since most programs exit on panic anyway. But it's causing rust-lang/rust-analyzer#9932, where when a proc macro panics in rust-analyzer, it locks the PDB file and making subsequent build attempts fail:
note: LINK : fatal error LNK1201: error writing to program database 'target\debug\deps***_derive-fd4461955b1f812b.pdb';
check for insufficient disk space, invalid path, or insufficient privilege
Steps to reproduce
// Run with `RUST_BACKTRACE=1`
fn main() {
let _ = std::panic::catch_unwind(|| panic!());
loop { std::thread::park(); }
}


Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Windows backtrace path that calls StackWalkEx and SymLoadModuleEx, then inspect how symbol modules are managed after a backtrace is printed. Use the provided catch_unwind reproduction with RUST_BACKTRACE=1 and verify that the PDB file is no longer held open while the process remains running.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100