diff options
| author | Ralf Jung <post@ralfj.de> | 2024-10-25 16:48:50 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-10-26 07:21:40 +0200 |
| commit | df9829c64dc0ada05473bead6a3ce9f078d8bb0a (patch) | |
| tree | 94a340796a904a7c7ab2f377b0102cc4d7b9a5a0 | |
| parent | 3432b91bbc863f8cacbb417afcfc1c0960740d9e (diff) | |
| download | rust-df9829c64dc0ada05473bead6a3ce9f078d8bb0a.tar.gz rust-df9829c64dc0ada05473bead6a3ce9f078d8bb0a.zip | |
indicate more explicitly where we close host file/dir handles
| -rw-r--r-- | src/tools/miri/src/shims/unix/fs.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tools/miri/src/shims/unix/fs.rs b/src/tools/miri/src/shims/unix/fs.rs index 4a94d3807a6..12020d64cbe 100644 --- a/src/tools/miri/src/shims/unix/fs.rs +++ b/src/tools/miri/src/shims/unix/fs.rs @@ -149,6 +149,7 @@ impl FileDescription for FileHandle { // to handle possible errors correctly. let result = self.file.sync_all(); // Now we actually close the file and return the result. + drop(*self); interp_ok(result) } else { // We drop the file, this closes it but ignores any errors @@ -157,6 +158,7 @@ impl FileDescription for FileHandle { // `/dev/urandom` which are read-only. Check // https://github.com/rust-lang/miri/issues/999#issuecomment-568920439 // for a deeper discussion. + drop(*self); interp_ok(Ok(())) } } @@ -1247,12 +1249,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { return this.set_last_error_and_return_i32(LibcError("EBADF")); } - let Some(open_dir) = this.machine.dirs.streams.remove(&dirp) else { + let Some(mut open_dir) = this.machine.dirs.streams.remove(&dirp) else { return this.set_last_error_and_return_i32(LibcError("EBADF")); }; - if let Some(entry) = open_dir.entry { + if let Some(entry) = open_dir.entry.take() { this.deallocate_ptr(entry, None, MiriMemoryKind::Runtime.into())?; } + // We drop the `open_dir`, which will close the host dir handle. drop(open_dir); interp_ok(Scalar::from_i32(0)) |
