On Sun Jun 22 16:12:01 2025 +0000, Jinoh Kang wrote:
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:
- *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!
FWIW, if Wine didn't have to patch proc/*/cmdline, then I would have simply said "just shift the argv array itself." That also makes the code simpler (as opposed to an assertion). After all, modifying argv is not a common occurrence in most programs as you said.