1
1
use rustc_middle:: { throw_unsup_format, ty} ;
2
2
use tracing:: debug;
3
3
4
+ use crate :: concurrency:: genmc:: MAX_ACCESS_SIZE ;
4
5
use crate :: concurrency:: thread:: EvalContextExt as _;
5
6
use crate :: * ;
6
7
@@ -27,10 +28,15 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
27
28
let this = self . eval_context_mut ( ) ;
28
29
let genmc_ctx = this. machine . data_race . as_genmc_ref ( ) . unwrap ( ) ;
29
30
31
+ let size = mutex. layout . size . bytes ( ) ;
32
+ assert ! (
33
+ size < MAX_ACCESS_SIZE ,
34
+ "Mutex is larger than maximal size of a memory access supported by GenMC ({size} >= {MAX_ACCESS_SIZE})"
35
+ ) ;
30
36
let result = genmc_ctx. handle . borrow_mut ( ) . pin_mut ( ) . handle_mutex_lock (
31
37
genmc_ctx. active_thread_genmc_tid ( & this. machine ) ,
32
38
mutex. ptr ( ) . addr ( ) . bytes ( ) ,
33
- mutex . layout . size . bytes ( ) ,
39
+ size,
34
40
) ;
35
41
if let Some ( error) = result. error . as_ref ( ) {
36
42
// FIXME(genmc): improve error handling.
@@ -87,10 +93,15 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
87
93
debug ! ( "GenMC: handling Mutex::try_lock()" ) ;
88
94
let this = self . eval_context_mut ( ) ;
89
95
let genmc_ctx = this. machine . data_race . as_genmc_ref ( ) . unwrap ( ) ;
96
+ let size = mutex. layout . size . bytes ( ) ;
97
+ assert ! (
98
+ size < MAX_ACCESS_SIZE ,
99
+ "Mutex is larger than maximal size of a memory access supported by GenMC ({size} >= {MAX_ACCESS_SIZE})"
100
+ ) ;
90
101
let result = genmc_ctx. handle . borrow_mut ( ) . pin_mut ( ) . handle_mutex_try_lock (
91
102
genmc_ctx. active_thread_genmc_tid ( & this. machine ) ,
92
103
mutex. ptr ( ) . addr ( ) . bytes ( ) ,
93
- mutex . layout . size . bytes ( ) ,
104
+ size,
94
105
) ;
95
106
if let Some ( error) = result. error . as_ref ( ) {
96
107
// FIXME(genmc): improve error handling.
0 commit comments