@@ -263,7 +263,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
263
263
None => this. eval_libc_i32 ( "EAGAIN" ) ,
264
264
}
265
265
} else {
266
- this . eval_libc_i32 ( "EINVAL" )
266
+ throw_ub_format ! ( "called pthread_mutex_lock on an unsupported type of mutex" ) ;
267
267
}
268
268
}
269
269
@@ -291,7 +291,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
291
291
None => this. eval_libc_i32 ( "EAGAIN" ) ,
292
292
}
293
293
} else {
294
- this . eval_libc_i32 ( "EINVAL" )
294
+ throw_ub_format ! ( "called pthread_mutex_trylock on an unsupported type of mutex" ) ;
295
295
}
296
296
}
297
297
@@ -306,9 +306,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
306
306
mutex_set_locked_count ( this, mutex_op, Scalar :: from_u32 ( 0 ) ) ?;
307
307
Ok ( 0 )
308
308
} else {
309
- throw_ub_format ! (
310
- "Attempted to unlock a PTHREAD_MUTEX_NORMAL mutex that was not locked"
311
- ) ;
309
+ throw_ub_format ! ( "unlocked a PTHREAD_MUTEX_NORMAL mutex that was not locked" ) ;
312
310
}
313
311
} else if kind == this. eval_libc ( "PTHREAD_MUTEX_ERRORCHECK" ) ? {
314
312
if locked_count != 0 {
@@ -329,15 +327,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
329
327
}
330
328
}
331
329
} else {
332
- this . eval_libc_i32 ( "EINVAL" )
330
+ throw_ub_format ! ( "called pthread_mutex_unlock on an unsupported type of mutex" ) ;
333
331
}
334
332
}
335
333
336
334
fn pthread_mutex_destroy ( & mut self , mutex_op : OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , i32 > {
337
335
let this = self . eval_context_mut ( ) ;
338
336
339
337
if mutex_get_locked_count ( this, mutex_op) ?. to_u32 ( ) ? != 0 {
340
- return this . eval_libc_i32 ( "EBUSY ") ;
338
+ throw_ub_format ! ( "destroyed a locked mutex ") ;
341
339
}
342
340
343
341
mutex_set_kind ( this, mutex_op, ScalarMaybeUndef :: Undef ) ?;
@@ -422,18 +420,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
422
420
rwlock_set_writers ( this, rwlock_op, Scalar :: from_u32 ( 0 ) ) ?;
423
421
Ok ( 0 )
424
422
} else {
425
- this . eval_libc_i32 ( "EPERM" )
423
+ throw_ub_format ! ( "unlocked an rwlock that was not locked" ) ;
426
424
}
427
425
}
428
426
429
427
fn pthread_rwlock_destroy ( & mut self , rwlock_op : OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , i32 > {
430
428
let this = self . eval_context_mut ( ) ;
431
429
432
- if rwlock_get_readers ( this, rwlock_op) ?. to_u32 ( ) ? != 0 {
433
- return this. eval_libc_i32 ( "EBUSY" ) ;
434
- }
435
- if rwlock_get_writers ( this, rwlock_op) ?. to_u32 ( ) ? != 0 {
436
- return this. eval_libc_i32 ( "EBUSY" ) ;
430
+ if rwlock_get_readers ( this, rwlock_op) ?. to_u32 ( ) ? != 0
431
+ || rwlock_get_writers ( this, rwlock_op) ?. to_u32 ( ) ? != 0
432
+ {
433
+ throw_ub_format ! ( "destroyed a locked rwlock" ) ;
437
434
}
438
435
439
436
rwlock_set_readers ( this, rwlock_op, ScalarMaybeUndef :: Undef ) ?;
0 commit comments