Skip to content
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

Printing backtrace will leak PDB file handles #470

Open
andylizi opened this issue May 22, 2022 · 1 comment
Open

Printing backtrace will leak PDB file handles #470

andylizi opened this issue May 22, 2022 · 1 comment

Comments

@andylizi
Copy link

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

@alexcrichton
Copy link
Member

One thing you might be able to try is to call SymCleanup perhaps? I think you'd need to call SymInitialize at some point afterwards though since this crate thinks that the symbols have already been initialized. I don't know precisely how this works internaly in dbghelp.dll though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants