Skip to content

Commit f480bbd

Browse files
committed
don't use opty args in create_thread
1 parent ff8973c commit f480bbd

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/shims/unix/thread.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
1313
) -> InterpResult<'tcx, i32> {
1414
let this = self.eval_context_mut();
1515

16+
let thread_info_place = this.deref_operand(thread)?;
17+
18+
let start_routine = this.read_pointer(start_routine)?;
19+
20+
let func_arg = this.read_immediate(arg)?;
21+
1622
this.start_thread(
17-
Some(thread),
23+
Some(thread_info_place),
1824
start_routine,
1925
Abi::C { unwind: false },
20-
arg,
26+
func_arg,
2127
this.layout_of(this.tcx.types.usize)?,
2228
)?;
2329

src/shims/windows/thread.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,40 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
1919
) -> InterpResult<'tcx, ThreadId> {
2020
let this = self.eval_context_mut();
2121

22-
if !this.ptr_is_null(this.read_pointer(security_op)?)? {
23-
throw_unsup_format!("non-null `lpThreadAttributes` in `CreateThread`")
24-
}
22+
let security = this.read_pointer(security_op)?;
2523

2624
// stacksize is ignored, but still needs to be a valid usize
2725
let _ = this.read_scalar(stacksize_op)?.to_machine_usize(this)?;
2826

27+
let start_routine = this.read_pointer(start_op)?;
28+
29+
let func_arg = this.read_immediate(arg_op)?;
30+
2931
let flags = this.read_scalar(flags_op)?.to_u32()?;
3032

33+
let thread = if this.ptr_is_null(this.read_pointer(thread_op)?)? {
34+
None
35+
} else {
36+
let thread_info_place = this.deref_operand(thread_op)?;
37+
Some(thread_info_place)
38+
};
39+
3140
let stack_size_param_is_a_reservation =
3241
this.eval_windows("c", "STACK_SIZE_PARAM_IS_A_RESERVATION")?.to_u32()?;
3342

3443
if flags != 0 && flags != stack_size_param_is_a_reservation {
3544
throw_unsup_format!("unsupported `dwCreationFlags` {} in `CreateThread`", flags)
3645
}
3746

38-
let thread =
39-
if this.ptr_is_null(this.read_pointer(thread_op)?)? { None } else { Some(thread_op) };
47+
if !this.ptr_is_null(security)? {
48+
throw_unsup_format!("non-null `lpThreadAttributes` in `CreateThread`")
49+
}
4050

4151
this.start_thread(
4252
thread,
43-
start_op,
53+
start_routine,
4454
Abi::System { unwind: false },
45-
arg_op,
55+
func_arg,
4656
this.layout_of(this.tcx.types.u32)?,
4757
)
4858
}

0 commit comments

Comments
 (0)