On Sun Jun 22 16:12:01 2025 +0000, Paris Oplopoios wrote:
You are correct, in that a proper emulator should push these arguments to the information block in the same order as the Linux kernel. It is also the case that most programs don't actually rely on the order that the things in the information blocks are pushed. So in reality most Linux programs would work despite the order they push the argument strings in the information block. The intention of this patch isn't to change this reliance. That's completely fine. It is an assert for future emulator developers that might land on this issue to save them a bit of debugging time. Yes, the emulator would be broken if it doesn't push them in the correct order. It has been fixed in my case. Personally it took me an hour or two to figure out what I was doing wrong, so I thought why not commit an assert in wine for anyone that might run into the same problem in the future? PS. If you think this is not something the wine project should care about, then I am fine with closing this merge request.
Wine *does* have many downstream wrappers and emulators (like Box64 and FEX-Emu), so it would be nice to make their jobs easier if possible.
That said, there are a million ways things can go wrong, and adding defensive asserts would make the code unreadable. For example, what about the argvs? PIE behaviors? prctl()s? Entry register states and/or TLS? Wine assumes that the platform works as expected, and it's emulator's job to ensure that.
IMHO there are two kinds of bugs in the systems world:
1. *Deterministic bugs*: with proper tooling, segfaults like this would be easy to hunt down. To save time debugging, simply diff with the reference implementation (e.g., diff the stack layouts from emulator and stock Linux). 2. *Heisenbugs*: there are more difficult to diagnose. They are also much "rarer," so adding a bit of assertions for them wouldn't be much of an hassle (notwithstanding the point above). Preloader is single-threaded and pretty much deterministic.
I'd be happy to see a separate project that tests/validates Linux ABI behaviors, so that other emulators like QEMU could also adopt them. Maybe it could already exist somewhere. But it's out of scope for Wine.
So yeah, closing seems appropriate. Thanks for your contribution nonetheless!