@@ -241,9 +241,11 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
241
241
// neither of which have any effect on our current PRNG
242
242
let _flags = this. read_scalar ( args[ 3 ] ) ?. to_i32 ( ) ?;
243
243
244
- let data = gen_random ( this, len as usize ) ?;
245
- this. memory_mut ( ) . get_mut ( ptr. alloc_id ) ?
246
- . write_bytes ( tcx, ptr, & data) ?;
244
+ if len > 0 {
245
+ let data = gen_random ( this, len as usize ) ?;
246
+ this. memory_mut ( ) . get_mut ( ptr. alloc_id ) ?
247
+ . write_bytes ( tcx, ptr, & data) ?;
248
+ }
247
249
248
250
this. write_scalar ( Scalar :: from_uint ( len, dest. layout . size ) , dest) ?;
249
251
}
@@ -622,6 +624,11 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
622
624
this. write_null ( dest) ?;
623
625
}
624
626
627
+ // We don't support fork so we don't have to do anything for atfork.
628
+ "pthread_atfork" => {
629
+ this. write_null ( dest) ?;
630
+ }
631
+
625
632
"mmap" => {
626
633
// This is a horrible hack, but since the guard page mechanism calls mmap and expects a particular return value, we just give it that value.
627
634
let addr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
@@ -767,11 +774,13 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
767
774
// The actual name of 'RtlGenRandom'
768
775
"SystemFunction036" => {
769
776
let ptr = this. read_scalar ( args[ 0 ] ) ?. to_ptr ( ) ?;
770
- let len = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this ) ?;
777
+ let len = this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?;
771
778
772
- let data = gen_random ( this, len as usize ) ?;
773
- this. memory_mut ( ) . get_mut ( ptr. alloc_id ) ?
774
- . write_bytes ( tcx, ptr, & data) ?;
779
+ if len > 0 {
780
+ let data = gen_random ( this, len as usize ) ?;
781
+ this. memory_mut ( ) . get_mut ( ptr. alloc_id ) ?
782
+ . write_bytes ( tcx, ptr, & data) ?;
783
+ }
775
784
776
785
this. write_scalar ( Scalar :: from_bool ( true ) , dest) ?;
777
786
}
0 commit comments