@@ -223,10 +223,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
223
223
F : FnOnce ( & mut MiriEvalContext < ' mir , ' tcx > , MutexId ) -> InterpResult < ' tcx , Option < MutexId > > ,
224
224
{
225
225
let this = self . eval_context_mut ( ) ;
226
- if let Some ( old) = existing ( this, this. machine . threads . sync . mutexes . next_index ( ) ) ? {
226
+ let next_index = this. machine . threads . sync . mutexes . next_index ( ) ;
227
+ if let Some ( old) = existing ( this, next_index) ? {
227
228
Ok ( old)
228
229
} else {
229
- Ok ( self . mutex_create ( ) )
230
+ let new_index = this. machine . threads . sync . mutexes . push ( Default :: default ( ) ) ;
231
+ assert_eq ! ( next_index, new_index) ;
232
+ Ok ( new_index)
230
233
}
231
234
}
232
235
@@ -323,10 +326,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
323
326
) -> InterpResult < ' tcx , Option < RwLockId > > ,
324
327
{
325
328
let this = self . eval_context_mut ( ) ;
326
- if let Some ( old) = existing ( this, this. machine . threads . sync . rwlocks . next_index ( ) ) ? {
329
+ let next_index = this. machine . threads . sync . rwlocks . next_index ( ) ;
330
+ if let Some ( old) = existing ( this, next_index) ? {
327
331
Ok ( old)
328
332
} else {
329
- Ok ( self . rwlock_create ( ) )
333
+ let new_index = this. machine . threads . sync . rwlocks . push ( Default :: default ( ) ) ;
334
+ assert_eq ! ( next_index, new_index) ;
335
+ Ok ( new_index)
330
336
}
331
337
}
332
338
@@ -489,10 +495,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
489
495
) -> InterpResult < ' tcx , Option < CondvarId > > ,
490
496
{
491
497
let this = self . eval_context_mut ( ) ;
492
- if let Some ( old) = existing ( this, this. machine . threads . sync . condvars . next_index ( ) ) ? {
498
+ let next_index = this. machine . threads . sync . condvars . next_index ( ) ;
499
+ if let Some ( old) = existing ( this, next_index) ? {
493
500
Ok ( old)
494
501
} else {
495
- Ok ( self . condvar_create ( ) )
502
+ let new_index = this. machine . threads . sync . condvars . push ( Default :: default ( ) ) ;
503
+ assert_eq ! ( next_index, new_index) ;
504
+ Ok ( new_index)
496
505
}
497
506
}
498
507
0 commit comments