http://bugs.winehq.org/show_bug.cgi?id=58420
Bug ID: 58420 Summary: Wine crashes when running msys2 iff CPU's PKU/PKRU feature is enabled Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: minor Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: pipcet@protonmail.com Distribution: ---
This is a heads-up about a bug in cygwin/msys2 which may be misreported as a wine bug.
The Cygwin code assumes CPUID leaf 0x0d to indicate in EBX a 64-byte-aligned value. That may or may not be true on current Windows systems, but on current Linux systems running Wine, with recent CPUs, a CPU feature called "PKU" or "PKRU" (memory protection keys for userspace), enabled by default, indicates an additional 8-byte XSAVE area.
This makes the Cygwin code attempt to xsave to a non-64-byte aligned area, which causes a segfault and abnormal program termination.
While this is clearly a bug, it's a bug that apparently cannot be triggered by current Windows systems. This means Wine fails to be bug-for-bug compatible in this case. I don't think there's an easy way around that: we'd have to trap XGETBV and CPUID instructions to pretend that a feature that is enabled by Linux actually isn't available.
It would have been nice if the Linux kernel had provided a way to disable the pku feature on a per-process basis, but AFAICT, it didn't. The nopku kernel command line argument makes things work, but requires a reboot and disables the very useful PKU feature for the entire system.
So I don't think there's a good workaround here, but maybe we should suggest to the Linux kernel people to allow per-process activation of any future XCR0 features?
http://bugs.winehq.org/show_bug.cgi?id=58420
Ken Sharp imwellcushtymelike@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source
http://bugs.winehq.org/show_bug.cgi?id=58420
Bernhard Übelacker bernhardu@mailbox.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bernhardu@mailbox.org
--- Comment #1 from Bernhard Übelacker bernhardu@mailbox.org --- Thank you very much for the detailed information.
Just putting a link to your cygwin upstream mailing list discussion: https://cygwin.com/pipermail/cygwin/2025-June/258368.html