Skip to content

Commit 911ff7e

Browse files
author
Vytautas Astrauskas
committed
Improve style and comments.
1 parent c4574dd commit 911ff7e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
211211
assert!(ecx.step()?, "a terminated thread was scheduled for execution");
212212
}
213213
SchedulingAction::ExecuteDtors => {
214-
ecx.schedule_tls_dtors_for_active_thread()?;
214+
ecx.schedule_next_tls_dtor_for_active_thread()?;
215215
}
216216
SchedulingAction::Stop => {
217217
break;

src/shims/tls.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ impl<'tcx> TlsData<'tcx> {
105105
match self.keys.get_mut(&key) {
106106
Some(TlsEntry { data, .. }) => {
107107
match new_data {
108-
Some(ptr) => {
109-
trace!("TLS key {} for thread {:?} stored: {:?}", key, thread_id, ptr);
110-
data.insert(thread_id, ptr);
108+
Some(scalar) => {
109+
trace!("TLS key {} for thread {:?} stored: {:?}", key, thread_id, scalar);
110+
data.insert(thread_id, scalar);
111111
}
112112
None => {
113113
trace!("TLS key {} for thread {:?} removed", key, thread_id);
@@ -271,7 +271,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
271271
if let Some((instance, ptr, key)) = dtor {
272272
this.machine.tls.last_dtor_key.insert(active_thread, key);
273273
trace!("Running TLS dtor {:?} on {:?} at {:?}", instance, ptr, active_thread);
274-
assert!(!this.is_null(ptr).unwrap(), "Data can't be NULL when dtor is called!");
274+
assert!(!this.is_null(ptr).unwrap(), "data can't be NULL when dtor is called!");
275275

276276
let ret_place = MPlaceTy::dangling(this.machine.layouts.unit, this).into();
277277
this.call_function(
@@ -295,10 +295,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
295295

296296
/// Schedule an active thread's TLS destructor to run on the active thread.
297297
/// Note that this function does not run the destructors itself, it just
298-
/// schedules them one by one each time it is called.
298+
/// schedules them one by one each time it is called and reenables the
299+
/// thread so that it can be executed normally by the main execution loop.
299300
///
300301
/// FIXME: we do not support yet deallocation of thread local statics.
301-
fn schedule_tls_dtors_for_active_thread(&mut self) -> InterpResult<'tcx> {
302+
/// Issue: https://github.com/rust-lang/miri/issues/1369
303+
fn schedule_next_tls_dtor_for_active_thread(&mut self) -> InterpResult<'tcx> {
302304
let this = self.eval_context_mut();
303305
let active_thread = this.get_active_thread()?;
304306

0 commit comments

Comments
 (0)