diff options
| author | Ralf Jung <post@ralfj.de> | 2019-11-29 22:57:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-29 22:57:42 +0100 |
| commit | 0f6745d6e287d1688c876fc5bc2ce8cad92c14cd (patch) | |
| tree | ec983cfb6f6f12cb4bd97b87dab14425b12a9a35 /src | |
| parent | 395937823c65d0dc6469e5df864b1e1b0f5a2b3f (diff) | |
| parent | 3048d7e5b54eb75c8a784e0270767436ec070729 (diff) | |
| download | rust-0f6745d6e287d1688c876fc5bc2ce8cad92c14cd.tar.gz rust-0f6745d6e287d1688c876fc5bc2ce8cad92c14cd.zip | |
Rollup merge of #66844 - RalfJung:caller-location-leak, r=oli-obk
Miri: do not consider memory allocated by caller_location leaked Fixes https://github.com/rust-lang/miri/issues/1071 r? @oli-obk I am not sure if this is the best approach, but it certainly is the easiest.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/interpret/intern.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/intrinsics/caller_location.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/memory.rs | 10 |
3 files changed, 9 insertions, 5 deletions
diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs index 630f3f60344..f9cb40ffe94 100644 --- a/src/librustc_mir/interpret/intern.rs +++ b/src/librustc_mir/interpret/intern.rs @@ -100,7 +100,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>( // This match is just a canary for future changes to `MemoryKind`, which most likely need // changes in this function. match kind { - MemoryKind::Stack | MemoryKind::Vtable => {}, + MemoryKind::Stack | MemoryKind::Vtable | MemoryKind::CallerLocation => {}, } // Set allocation mutability as appropriate. This is used by LLVM to put things into // read-only memory, and also by Miri when evluating other constants/statics that diff --git a/src/librustc_mir/interpret/intrinsics/caller_location.rs b/src/librustc_mir/interpret/intrinsics/caller_location.rs index 88bfcd63129..9e07a3f1072 100644 --- a/src/librustc_mir/interpret/intrinsics/caller_location.rs +++ b/src/librustc_mir/interpret/intrinsics/caller_location.rs @@ -28,7 +28,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let file = Scalar::Ptr(self.tag_static_base_pointer(file_ptr)); let file_len = Scalar::from_uint(filename.as_str().len() as u128, ptr_size); - let location = self.allocate(loc_layout, MemoryKind::Stack); + let location = self.allocate(loc_layout, MemoryKind::CallerLocation); let file_out = self.mplace_field(location, 0)?; let file_ptr_out = self.force_ptr(self.mplace_field(file_out, 0)?.ptr)?; diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index eccdc5b0326..a8011f7abb1 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -24,11 +24,13 @@ use super::{ #[derive(Debug, PartialEq, Copy, Clone)] pub enum MemoryKind<T> { - /// Error if deallocated except during a stack pop + /// Stack memory. Error if deallocated except during a stack pop. Stack, - /// Error if ever deallocated + /// Memory backing vtables. Error if ever deallocated. Vtable, - /// Additional memory kinds a machine wishes to distinguish from the builtin ones + /// Memory allocated by `caller_location` intrinsic. Error if ever deallocated. + CallerLocation, + /// Additional memory kinds a machine wishes to distinguish from the builtin ones. Machine(T), } @@ -38,6 +40,7 @@ impl<T: MayLeak> MayLeak for MemoryKind<T> { match self { MemoryKind::Stack => false, MemoryKind::Vtable => true, + MemoryKind::CallerLocation => true, MemoryKind::Machine(k) => k.may_leak() } } @@ -719,6 +722,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { let extra = match kind { MemoryKind::Stack => " (stack)".to_owned(), MemoryKind::Vtable => " (vtable)".to_owned(), + MemoryKind::CallerLocation => " (caller_location)".to_owned(), MemoryKind::Machine(m) => format!(" ({:?})", m), }; self.dump_alloc_helper( |
