Doing xshell::pushd with a directory created with xshell::mktemp_d panics
chris-ricketts opened this issue · comments
It seems like an obvious use but I'm probably missing something. Is this behavior intended?
fn main() {
println!(
"Current working directory: {}",
xshell::cwd().unwrap().display()
);
let tmp = xshell::mktemp_d().unwrap();
println!("Created temporary directory: {}", tmp.path().display());
// Enter directory in child block so pushd guard is dropped before tmp
{
let _cwd = xshell::pushd(tmp.path()).unwrap();
println!(
"Current working directory: {}",
xshell::cwd().unwrap().display()
);
}
}
Gives:
Current working directory: /path/to/example/
Created temporary directory: /tmp/xshell-tmp-dir-0
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `1`,
right: `0`: calling write() with an active read guard on the same thread would deadlock', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/xshell-0.1.14/src/gsl.rs:44:13
Heh, that's definitely a bug, and a pretty bad one, cc @azdavis .
Off the top of my head, I don't know how to fix -- do we even have an upgradable read-writer lock, such that any concurrent read can be upgraded? (IIRC, in parking lot upgradable reads block each other)