diff options
| author | Ralf Jung <post@ralfj.de> | 2022-04-17 19:16:54 -0400 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-04-17 19:16:54 -0400 |
| commit | 85ee04c44a1d4ffc2f2e3bb0c217908ce4062a18 (patch) | |
| tree | ede3d143d9ac3e9fc0db8c20af2f3de91f74aed4 /compiler/rustc_const_eval/src/interpret | |
| parent | ad4e98ed7dc535d161886b17f7792501baa82c9b (diff) | |
| download | rust-85ee04c44a1d4ffc2f2e3bb0c217908ce4062a18.tar.gz rust-85ee04c44a1d4ffc2f2e3bb0c217908ce4062a18.zip | |
when writing uninit to an allocation, also clear relocations like other writes do
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/memory.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/place.rs | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index a165fa23f30..32b739f9335 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -892,8 +892,11 @@ impl<'tcx, 'a, Tag: Provenance, Extra> AllocRefMut<'a, 'tcx, Tag, Extra> { } /// Mark the entire referenced range as uninitalized - pub fn write_uninit(&mut self) { - self.alloc.mark_init(self.range, false); + pub fn write_uninit(&mut self) -> InterpResult<'tcx> { + Ok(self + .alloc + .write_uninit(&self.tcx, self.range) + .map_err(|e| e.to_interp_error(self.alloc_id))?) } } @@ -1053,8 +1056,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // This also avoids writing to the target bytes so that the backing allocation is never // touched if the bytes stay uninitialized for the whole interpreter execution. On contemporary // operating system this can avoid physically allocating the page. - dest_alloc.mark_init(dest_range, false); // `Size` multiplication - dest_alloc.mark_relocation_range(relocations); + dest_alloc + .write_uninit(&tcx, dest_range) + .map_err(|e| e.to_interp_error(dest_alloc_id))?; // `Size` multiplication + // We can forget about the relocations, this is all not initialized anyway. return Ok(()); } diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 31da4522a1f..e4660fe090c 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -823,7 +823,7 @@ where // Zero-sized access return Ok(()); }; - alloc.write_uninit(); + alloc.write_uninit()?; Ok(()) } |
