1
+ use std:: env;
1
2
use std:: ffi:: { OsStr , OsString } ;
2
3
use std:: io:: ErrorKind ;
3
- use std:: { env, mem} ;
4
4
5
5
use rustc_abi:: { FieldIdx , Size } ;
6
6
use rustc_data_structures:: fx:: FxHashMap ;
@@ -50,20 +50,6 @@ impl<'tcx> UnixEnvVars<'tcx> {
50
50
interp_ok ( UnixEnvVars { map : env_vars_machine, environ } )
51
51
}
52
52
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
-
67
53
pub ( crate ) fn environ ( & self ) -> Pointer {
68
54
self . environ . ptr ( )
69
55
}
@@ -112,7 +98,7 @@ fn alloc_env_var<'tcx>(
112
98
let mut name_osstring = name. to_os_string ( ) ;
113
99
name_osstring. push ( "=" ) ;
114
100
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 ( ) )
116
102
}
117
103
118
104
/// Allocates an `environ` block with the given list of pointers.
@@ -128,7 +114,7 @@ fn alloc_environ_block<'tcx>(
128
114
ecx. machine . layouts . mut_raw_ptr . ty ,
129
115
u64:: try_from ( vars. len ( ) ) . unwrap ( ) ,
130
116
) ) ?;
131
- let vars_place = ecx. allocate ( vars_layout, MiriMemoryKind :: Runtime . into ( ) ) ?;
117
+ let vars_place = ecx. allocate ( vars_layout, MiriMemoryKind :: Machine . into ( ) ) ?;
132
118
for ( idx, var) in vars. into_iter_enumerated ( ) {
133
119
let place = ecx. project_field ( & vars_place, idx) ?;
134
120
ecx. write_pointer ( var, & place) ?;
@@ -171,7 +157,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
171
157
if let Some ( ( name, value) ) = new {
172
158
let var_ptr = alloc_env_var ( this, & name, & value) ?;
173
159
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 ( ) ) ?;
175
161
}
176
162
this. update_environ ( ) ?;
177
163
interp_ok ( Scalar :: from_i32 ( 0 ) ) // return zero on success
@@ -195,7 +181,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
195
181
}
196
182
if let Some ( old) = success {
197
183
if let Some ( var) = old {
198
- this. deallocate_ptr ( var, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
184
+ this. deallocate_ptr ( var, None , MiriMemoryKind :: Machine . into ( ) ) ?;
199
185
}
200
186
this. update_environ ( ) ?;
201
187
interp_ok ( Scalar :: from_i32 ( 0 ) )
@@ -253,7 +239,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
253
239
// Deallocate the old environ list.
254
240
let environ = this. machine . env_vars . unix ( ) . environ . clone ( ) ;
255
241
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 ( ) ) ?;
257
243
258
244
// Write the new list.
259
245
let vals = this. machine . env_vars . unix ( ) . map . values ( ) . copied ( ) . collect ( ) ;
0 commit comments