1+ use std:: env;
12use std:: ffi:: { OsStr , OsString } ;
23use std:: io:: ErrorKind ;
3- use std:: { env, mem} ;
44
55use rustc_abi:: { FieldIdx , Size } ;
66use rustc_data_structures:: fx:: FxHashMap ;
@@ -50,20 +50,6 @@ impl<'tcx> UnixEnvVars<'tcx> {
5050 interp_ok ( UnixEnvVars { map : env_vars_machine, environ } )
5151 }
5252
53- pub ( crate ) fn cleanup ( ecx : & mut InterpCx < ' tcx , MiriMachine < ' tcx > > ) -> InterpResult < ' tcx > {
54- // Deallocate individual env vars.
55- let env_vars = mem:: take ( & mut ecx. machine . env_vars . unix_mut ( ) . map ) ;
56- for ( _name, ptr) in env_vars {
57- ecx. deallocate_ptr ( ptr, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
58- }
59- // Deallocate environ var list.
60- let environ = & ecx. machine . env_vars . unix ( ) . environ ;
61- let old_vars_ptr = ecx. read_pointer ( environ) ?;
62- ecx. deallocate_ptr ( old_vars_ptr, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
63-
64- interp_ok ( ( ) )
65- }
66-
6753 pub ( crate ) fn environ ( & self ) -> Pointer {
6854 self . environ . ptr ( )
6955 }
@@ -112,7 +98,7 @@ fn alloc_env_var<'tcx>(
11298 let mut name_osstring = name. to_os_string ( ) ;
11399 name_osstring. push ( "=" ) ;
114100 name_osstring. push ( value) ;
115- ecx. alloc_os_str_as_c_str ( name_osstring. as_os_str ( ) , MiriMemoryKind :: Runtime . into ( ) )
101+ ecx. alloc_os_str_as_c_str ( name_osstring. as_os_str ( ) , MiriMemoryKind :: Machine . into ( ) )
116102}
117103
118104/// Allocates an `environ` block with the given list of pointers.
@@ -128,7 +114,7 @@ fn alloc_environ_block<'tcx>(
128114 ecx. machine . layouts . mut_raw_ptr . ty ,
129115 u64:: try_from ( vars. len ( ) ) . unwrap ( ) ,
130116 ) ) ?;
131- let vars_place = ecx. allocate ( vars_layout, MiriMemoryKind :: Runtime . into ( ) ) ?;
117+ let vars_place = ecx. allocate ( vars_layout, MiriMemoryKind :: Machine . into ( ) ) ?;
132118 for ( idx, var) in vars. into_iter_enumerated ( ) {
133119 let place = ecx. project_field ( & vars_place, idx) ?;
134120 ecx. write_pointer ( var, & place) ?;
@@ -171,7 +157,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
171157 if let Some ( ( name, value) ) = new {
172158 let var_ptr = alloc_env_var ( this, & name, & value) ?;
173159 if let Some ( var) = this. machine . env_vars . unix_mut ( ) . map . insert ( name, var_ptr) {
174- this. deallocate_ptr ( var, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
160+ this. deallocate_ptr ( var, None , MiriMemoryKind :: Machine . into ( ) ) ?;
175161 }
176162 this. update_environ ( ) ?;
177163 interp_ok ( Scalar :: from_i32 ( 0 ) ) // return zero on success
@@ -195,7 +181,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
195181 }
196182 if let Some ( old) = success {
197183 if let Some ( var) = old {
198- this. deallocate_ptr ( var, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
184+ this. deallocate_ptr ( var, None , MiriMemoryKind :: Machine . into ( ) ) ?;
199185 }
200186 this. update_environ ( ) ?;
201187 interp_ok ( Scalar :: from_i32 ( 0 ) )
@@ -253,7 +239,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
253239 // Deallocate the old environ list.
254240 let environ = this. machine . env_vars . unix ( ) . environ . clone ( ) ;
255241 let old_vars_ptr = this. read_pointer ( & environ) ?;
256- this. deallocate_ptr ( old_vars_ptr, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
242+ this. deallocate_ptr ( old_vars_ptr, None , MiriMemoryKind :: Machine . into ( ) ) ?;
257243
258244 // Write the new list.
259245 let vals = this. machine . env_vars . unix ( ) . map . values ( ) . copied ( ) . collect ( ) ;
0 commit comments