Change:
<!-- Thank you for filing a regression report! A regression is something that changed between versions of Rust but was not supposed to. Please provide a short summary of the regression, along with any information you feel is relevant to replicate it. --The Windows implementation of spawning a process creates a structure and sets its member to the size of the structure: On stable and beta, this works correctly and the size is set to 0x68. However, on nightly, the compiler compiles the to a garbage value: Note that that value ( in the example above) changes with each rebuild of the program in question. This can be verified by setting a breakpoint on the call to or one of the functions that it calls and examining the structure on the stack (e.g. setting a breakpoint on and reinterpreting as ). <!-- Provide the most recent version this worked on, for example: It most recently worked on: Rust 1.47 --It most recently worked on: rustc 1.73.0-beta.4 ( 2023-09-01) <!-- Provide the version you are using that has the regression. --: <!-- If you know when this regression occurred, please add a line like below, replacing with one of stable, beta, or nightly. modify labels: +regression-from-beta-to-nightly -regression-untriaged -- modify labels: +regression-from-beta-to-nightly -regression-untriaged
Ah, sorry I missed the lack of in review. Though it is a bit concerning that our tests didn't catch it either. If someone wants to make a quick PR to fix it, I'd appreciate it.
Also cc
Heh, missed that too, explains the ... I'll make a PR. (How is casting a function pointer, which is 64bit, to a , which is 32bit, safe Rust though?)
Yeah is bad. I mean, casting is completely safe in Rust... but using the result of the cast isn't necessarily.
Can't believe this compiled, didn't know that you could cast a function to an in safe rust. Really sorry for this <3
It's ok. It's subtle and we both missed it. An cast is way too powerful for its own good.
Maybe we should make a clippy lint for this.
Just out of interest, how did you discover this?
At least one clippy lint already exists, and it warns by default https://rust- Though the lint I would prefer here is warning against ever taking the address of a generic function.
I was actually trying to get some handle information about the handles passes to the process it spawns since I wanted to figure out why it didn't print any output when the process being tested is a GUI process (I was assuming it was trying to pass console driver handles to the process, which wouldn't work since the child process wouldn't have a console attached), and my Rust knowledge was still weak enough that looking at the handles in a debugger was easier than to dig through three files of defaults and fallbacks, so I set a breakpoint, looked at the and discovered that the value was way too big.
It's a cast that doesn't make any sense though - on a 64bit platform, a Rust function pointer can never fit into 32 bits, so requiring it to go through an intermediary, e.g. , could help prevent such accidents.
supports numerous truncating conversions, which is indeed one of the problems with it.

Discussion:
}; si_ptr = &mut si_ex as *mut _ as _; } else { <del> si.cb = mem::size_of::<c::STARTUPINFOW> as c::DWORD; </del> <ins> si.cb = mem::size_of::<c::STARTUPINFOW>() as c::DWORD; </ins> si_ptr = &mut si as *mut _ as _; }