rust-lang / rust-lang/backtrace-rs

Printing backtrace will leak PDB file handles

Open
#470 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

OS-windows
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(); }
}

process-modules
procmon

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.