@@ -6,6 +6,7 @@ use rustc::{ty, ty::layout::HasDataLayout, mir};
6
6
use crate :: {
7
7
InterpResult , InterpError , StackPopCleanup ,
8
8
MPlaceTy , Scalar , Tag ,
9
+ HelpersEvalContextExt ,
9
10
} ;
10
11
11
12
pub type TlsKey = u128 ;
@@ -111,7 +112,6 @@ impl<'tcx> TlsData<'tcx> {
111
112
fn fetch_tls_dtor (
112
113
& mut self ,
113
114
key : Option < TlsKey > ,
114
- cx : & impl HasDataLayout ,
115
115
) -> Option < ( ty:: Instance < ' tcx > , Scalar < Tag > , TlsKey ) > {
116
116
use std:: collections:: Bound :: * ;
117
117
@@ -123,10 +123,10 @@ impl<'tcx> TlsData<'tcx> {
123
123
for ( & key, & mut TlsEntry { ref mut data, dtor } ) in
124
124
thread_local. range_mut ( ( start, Unbounded ) )
125
125
{
126
- if let Some ( ref mut data ) = * data {
126
+ if let Some ( data_scalar ) = * data {
127
127
if let Some ( dtor) = dtor {
128
- let ret = Some ( ( dtor, * data , key) ) ;
129
- * data = Scalar :: ptr_null ( cx ) ;
128
+ let ret = Some ( ( dtor, data_scalar , key) ) ;
129
+ * data = None ;
130
130
return ret;
131
131
}
132
132
}
@@ -139,10 +139,11 @@ impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tc
139
139
pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriEvalContextExt < ' mir , ' tcx > {
140
140
fn run_tls_dtors ( & mut self ) -> InterpResult < ' tcx > {
141
141
let this = self . eval_context_mut ( ) ;
142
- let mut dtor = this. machine . tls . fetch_tls_dtor ( None , & * this . tcx ) ;
142
+ let mut dtor = this. machine . tls . fetch_tls_dtor ( None ) ;
143
143
// FIXME: replace loop by some structure that works with stepping
144
144
while let Some ( ( instance, ptr, key) ) = dtor {
145
145
trace ! ( "Running TLS dtor {:?} on {:?}" , instance, ptr) ;
146
+ assert ! ( !this. is_null( ptr) . unwrap( ) , "Data can't be NULL when dtor is called!" ) ;
146
147
// TODO: Potentially, this has to support all the other possible instances?
147
148
// See eval_fn_call in interpret/terminator/mod.rs
148
149
let mir = this. load_mir ( instance. def ) ?;
@@ -163,9 +164,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
163
164
// step until out of stackframes
164
165
this. run ( ) ?;
165
166
166
- dtor = match this. machine . tls . fetch_tls_dtor ( Some ( key) , & * this . tcx ) {
167
+ dtor = match this. machine . tls . fetch_tls_dtor ( Some ( key) ) {
167
168
dtor @ Some ( _) => dtor,
168
- None => this. machine . tls . fetch_tls_dtor ( None , & * this . tcx ) ,
169
+ None => this. machine . tls . fetch_tls_dtor ( None ) ,
169
170
} ;
170
171
}
171
172
// FIXME: On a windows target, call `unsafe extern "system" fn on_tls_callback`.
0 commit comments