@@ -43,7 +43,7 @@ struct ExitStatus {
43
43
pub struct GenmcCtx {
44
44
handle : RefCell < UniquePtr < MiriGenMCShim > > ,
45
45
46
- // TODO GENMC (PERFORMANCE): could use one RefCell for all internals instead of multiple
46
+ // FIXME(genmc,performance): we could use one RefCell for all internals instead of multiple
47
47
thread_infos : RefCell < ThreadInfoManager > ,
48
48
49
49
/// Some actions Miri does are allowed to cause data races.
@@ -54,6 +54,8 @@ pub struct GenmcCtx {
54
54
/// The `AllocId` for globals is stable across executions, so we can use it as an identifier.
55
55
global_allocations : Arc < GlobalAllocationHandler > ,
56
56
57
+ /// The exit status of the program.
58
+ /// `None` if no thread has called `exit` and the main thread isn't finished yet.
57
59
exit_status : Cell < Option < ExitStatus > > ,
58
60
}
59
61
@@ -126,9 +128,10 @@ impl GenmcCtx {
126
128
let mut mc = self . handle . borrow_mut ( ) ;
127
129
let result = mc. as_mut ( ) . unwrap ( ) . handleExecutionEnd ( ) ;
128
130
if let Some ( msg) = result. as_ref ( ) {
131
+ // FIXME(genmc): error handling (may need changes on GenMC side first).
129
132
let msg = msg. to_string_lossy ( ) . to_string ( ) ;
130
133
info ! ( "GenMC: execution ended with error \" {msg}\" " ) ;
131
- Err ( msg) // TODO GENMC: add more error info here, and possibly handle this without requiring to clone the CxxString
134
+ Err ( msg)
132
135
} else {
133
136
Ok ( ( ) )
134
137
}
@@ -162,7 +165,7 @@ impl GenmcCtx {
162
165
old_val : Option < Scalar > ,
163
166
) -> InterpResult < ' tcx , Scalar > {
164
167
info ! ( "GenMC: atomic_load: old_val: {old_val:?}" ) ;
165
- assert ! ( !self . allow_data_races. get( ) ) ; // TODO GENMC: handle this properly
168
+ assert ! ( !self . allow_data_races. get( ) ) ; // FIXME(genmc): ensure correct behavior whereever `allow_data_races` is used.
166
169
let ordering = ordering. convert ( ) ;
167
170
let genmc_old_value = option_scalar_to_genmc_scalar ( ecx, old_val) ?;
168
171
let read_value =
@@ -181,7 +184,7 @@ impl GenmcCtx {
181
184
old_value : Option < Scalar > ,
182
185
ordering : AtomicWriteOrd ,
183
186
) -> InterpResult < ' tcx , bool > {
184
- assert ! ( !self . allow_data_races. get( ) ) ; // TODO GENMC: handle this properly
187
+ assert ! ( !self . allow_data_races. get( ) ) ;
185
188
let ordering = ordering. convert ( ) ;
186
189
let genmc_value = scalar_to_genmc_scalar ( ecx, value) ?;
187
190
let genmc_old_value = option_scalar_to_genmc_scalar ( ecx, old_value) ?;
@@ -319,7 +322,6 @@ impl GenmcCtx {
319
322
machine : & MiriMachine < ' tcx > ,
320
323
address : Size ,
321
324
size : Size ,
322
- // old_value: Option<Scalar>, // TODO GENMC(mixed atomic-non-atomic): is this needed?
323
325
) -> InterpResult < ' tcx > {
324
326
info ! (
325
327
"GenMC: received memory_store (non-atomic): address: {:#x}, size: {}" ,
@@ -336,7 +338,6 @@ impl GenmcCtx {
336
338
}
337
339
338
340
if size. bytes ( ) <= 8 {
339
- // TODO GENMC(mixed atomic-non-atomics): anything to do here?
340
341
let _is_co_max_write = self . atomic_store_impl (
341
342
machine,
342
343
address,
@@ -436,7 +437,6 @@ impl GenmcCtx {
436
437
let pinned_mc = mc. as_mut ( ) . unwrap ( ) ;
437
438
pinned_mc. handleFree ( genmc_tid. 0 , genmc_address, genmc_size) ;
438
439
439
- // TODO GENMC (ERROR HANDLING): can this ever fail?
440
440
interp_ok ( ( ) )
441
441
}
442
442
@@ -445,11 +445,11 @@ impl GenmcCtx {
445
445
pub ( crate ) fn handle_thread_create < ' tcx > (
446
446
& self ,
447
447
threads : & ThreadManager < ' tcx > ,
448
- _start_routine : crate :: Pointer , // TODO GENMC: pass info to GenMC
448
+ _start_routine : crate :: Pointer , // FIXME(genmc): symmetry reduction will need this info
449
449
_func_arg : & crate :: ImmTy < ' tcx > ,
450
450
new_thread_id : ThreadId ,
451
451
) -> InterpResult < ' tcx > {
452
- assert ! ( !self . allow_data_races. get( ) ) ; // TODO GENMC: handle this properly
452
+ assert ! ( !self . allow_data_races. get( ) ) ;
453
453
let mut thread_infos = self . thread_infos . borrow_mut ( ) ;
454
454
455
455
let curr_thread_id = threads. active_thread ( ) ;
@@ -467,7 +467,7 @@ impl GenmcCtx {
467
467
active_thread_id : ThreadId ,
468
468
child_thread_id : ThreadId ,
469
469
) -> InterpResult < ' tcx > {
470
- assert ! ( !self . allow_data_races. get( ) ) ; // TODO GENMC: handle this properly
470
+ assert ! ( !self . allow_data_races. get( ) ) ;
471
471
let thread_infos = self . thread_infos . borrow ( ) ;
472
472
473
473
let genmc_curr_tid = thread_infos. get_info ( active_thread_id) . genmc_tid ;
@@ -480,7 +480,7 @@ impl GenmcCtx {
480
480
}
481
481
482
482
pub ( crate ) fn handle_thread_finish < ' tcx > ( & self , threads : & ThreadManager < ' tcx > ) {
483
- assert ! ( !self . allow_data_races. get( ) ) ; // TODO GENMC: handle this properly
483
+ assert ! ( !self . allow_data_races. get( ) ) ;
484
484
let curr_thread_id = threads. active_thread ( ) ;
485
485
486
486
let thread_infos = self . thread_infos . borrow ( ) ;
@@ -544,7 +544,7 @@ impl GenmcCtx {
544
544
if size. bytes ( ) > 8 {
545
545
throw_unsup_format ! ( "{UNSUPPORTED_ATOMICS_SIZE_MSG}" ) ;
546
546
}
547
- assert ! ( !self . allow_data_races. get( ) ) ; // TODO GENMC: handle this properly
547
+ assert ! ( !self . allow_data_races. get( ) ) ;
548
548
let thread_infos = self . thread_infos . borrow ( ) ;
549
549
let curr_thread_id = machine. threads . active_thread ( ) ;
550
550
let genmc_tid = thread_infos. get_info ( curr_thread_id) . genmc_tid ;
@@ -571,9 +571,10 @@ impl GenmcCtx {
571
571
}
572
572
573
573
if let Some ( error) = load_result. error . as_ref ( ) {
574
+ // FIXME(genmc): error handling
574
575
let msg = error. to_string_lossy ( ) . to_string ( ) ;
575
576
info ! ( "GenMC: load operation returned an error: \" {msg}\" " ) ;
576
- throw_ub_format ! ( "{}" , msg) ; // TODO GENMC: proper error handling: find correct error here
577
+ throw_ub_format ! ( "{}" , msg) ;
577
578
}
578
579
579
580
info ! ( "GenMC: load returned value: {:?}" , load_result. read_value) ;
@@ -621,9 +622,10 @@ impl GenmcCtx {
621
622
) ;
622
623
623
624
if let Some ( error) = store_result. error . as_ref ( ) {
625
+ // FIXME(genmc): error handling
624
626
let msg = error. to_string_lossy ( ) . to_string ( ) ;
625
627
info ! ( "GenMC: store operation returned an error: \" {msg}\" " ) ;
626
- throw_ub_format ! ( "{}" , msg) ; // TODO GENMC: proper error handling: find correct error here
628
+ throw_ub_format ! ( "{}" , msg) ;
627
629
}
628
630
629
631
interp_ok ( store_result. isCoMaxWrite )
@@ -635,7 +637,7 @@ impl GenmcCtx {
635
637
& self ,
636
638
ecx : & InterpCx < ' tcx , MiriMachine < ' tcx > > ,
637
639
) -> InterpResult < ' tcx , ThreadId > {
638
- assert ! ( !self . allow_data_races. get( ) ) ; // TODO GENMC: handle this properly
640
+ assert ! ( !self . allow_data_races. get( ) ) ;
639
641
let thread_manager = & ecx. machine . threads ;
640
642
let active_thread_id = thread_manager. active_thread ( ) ;
641
643
@@ -674,7 +676,6 @@ impl GenmcCtx {
674
676
let result =
675
677
pinned_mc. scheduleNext ( curr_thread_info. genmc_tid . 0 , curr_thread_next_instr_kind) ;
676
678
if result >= 0 {
677
- // TODO GENMC: can we ensure this thread_id is valid?
678
679
let genmc_next_thread_id = result. try_into ( ) . unwrap ( ) ;
679
680
let genmc_next_thread_id = GenmcThreadId ( genmc_next_thread_id) ;
680
681
let thread_infos = self . thread_infos . borrow ( ) ;
0 commit comments