Skip to content
Prev Previous commit
adjust MemoryKind comment
  • Loading branch information
RalfJung authored Mar 27, 2020
commit 579b3c49dac9def1495f7d97d4f5b2771bbeefd8
8 changes: 2 additions & 6 deletions src/shims/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
}
// Allocate environment block & Store environment variables to environment block.
// Final null terminator(block terminator) is added by `alloc_os_str_to_wide_str`.
// FIXME: MemoryKind should be `MiMemoryKind::Machine`,
// but using it results in a Stacked Borrows error when running MIRI on 'tests/run-pass/env.rs'
// For now, use `MiriMemoryKind::WinHeap` instead.
// FIXME: MemoryKind should be `Machine`, blocked on https://github.com/rust-lang/rust/pull/70479.
let envblock_ptr = this.alloc_os_str_as_wide_str(&env_vars, MiriMemoryKind::WinHeap.into());
// If the function succeeds, the return value is a pointer to the environment block of the current process.
Ok(envblock_ptr.into())
Expand All @@ -160,9 +158,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
this.assert_target_os("windows", "FreeEnvironmentStringsW");

let env_block_ptr = this.read_scalar(env_block_op)?.not_undef()?;
// FIXME: MemoryKind should be `MiMemoryKind::Machine`,
// but using it results in a Stacked Borrows error when running MIRI on 'tests/run-pass/env.rs'
// For now, use `MiriMemoryKind::WinHeap` instead.
// FIXME: MemoryKind should be `Machine`, blocked on https://github.com/rust-lang/rust/pull/70479.
let result = this.memory.deallocate(this.force_ptr(env_block_ptr)?, None, MiriMemoryKind::WinHeap.into());
// If the function succeeds, the return value is nonzero.
Ok(result.is_ok() as i32)
Expand Down