https://bugs.winehq.org/show_bug.cgi?id=52715
Bug ID: 52715 Summary: wine segfaults on asahi linux (apple M1 hardware, linux kernel/userland) Product: Wine Version: 7.4 Hardware: aarch64 OS: Linux Status: NEW Keywords: source Severity: blocker Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: austinenglish@gmail.com Distribution: Debian
The GCC Compile Farm has a m1 machine running asahi linux, so I tried building wine. While it compiles (note: most optional deps and freetype were missing), the resulting binary segfaults, even for --version/--help:
austin@gcc103:~/wine$ file loader/wine loader/wine: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=c47e4c565e49cc68efce4887d600f06d749670e0, for GNU/Linux 3.7.0, with debug_info, not stripped
austin@gcc103:~/wine$ ./loader/wine --version Segmentation fault
austin@gcc103:~/wine$ ./loader/wine --help Segmentation fault
austin@gcc103:~/wine$ uname -a Linux gcc103.fsffrance.org 5.17.0-rc7-asahi-next-20220310-g4a4f4ec03834 #1 SMP PREEMPT Sat Mar 12 18:16:45 UTC 2022 aarch64 GNU/Linux
austin@gcc103:~/wine$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/11/lto-wrapper Target: aarch64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 11.2.0-18' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=4 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (Debian 11.2.0-18)
austin@gcc103:~/wine$ ~/llvm-mingw-20211002-ucrt-ubuntu-18.04-aarch64/bin/aarch64-w64-mingw32-gcc --version clang version 13.0.0 (https://github.com/llvm/llvm-project.git d7b669b3a30345cfcdb2fde2af6f48aa4b94845d) Target: aarch64-w64-windows-gnu Thread model: posix InstalledDir: /home/austin/llvm-mingw-20211002-ucrt-ubuntu-18.04-aarch64/bin
Note that the machine uses a 16k stack size instead of 4k, which may be at fault: https://github.com/AsahiLinux/docs/wiki/Software-known-to-have-issues-with-1...
https://bugs.winehq.org/show_bug.cgi?id=52715
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dark.shadow4@web.de
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #1 from Fabian Maurer dark.shadow4@web.de --- This is indeed due to the page size. The "wine" binary is compiled with "-Wl,-z,max-page-size=0x1000". Remove that, and it doesn't segfault. It doesn't work still, but at least it doesn't crash instantly.
https://bugs.winehq.org/show_bug.cgi?id=52715
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Blocks| |52934
--- Comment #2 from Fabian Maurer dark.shadow4@web.de --- Added follow up bug 52934. Might also be dependent on 16k pages, not not, I don't know. Although I'm not sure how useful it is to try and make wine work on 16k pages.
https://bugs.winehq.org/show_bug.cgi?id=52715
Dustin Hacker ldhacker2@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |ldhacker2@gmail.com
--- Comment #3 from Dustin Hacker ldhacker2@gmail.com --- I was able to get it not to segfault by changing every instance of -max-page-size=0x1000 to -max-page-size=0x4000 in the ./configure script. Also, I changed a few instances of the page zero size to 0x4000 as well.
The ./configure setup that I use is:
./configure --host=aarch64-linux-gnu host_alias=aarch64-linux-gnu --without-freetype --without-x --enable-win64
I got the ./configure info from https://wiki.winehq.org/ARM64 aand modified it to be for aarch64.
Now it runs without segfault, but I get he following error on trying to run an .exe:
wine: failed to load /usr/local/lib/wine/aarch64-windows/ntdll.dll error c000007b 0024:err:environ:run_wineboot failed to start wineboot c00000e5 wine: failed to load /usr/local/lib/wine/aarch64-windows/ntdll.dll error c000007b
https://bugs.winehq.org/show_bug.cgi?id=52715
André H. nerv@dawncrow.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nerv@dawncrow.de
--- Comment #4 from André H. nerv@dawncrow.de --- For reference, this is what I did for 64k pages on PowerPC64le:
https://github.com/AndreRH/wine/commit/8db73261d4a18b50cd9aa3f0ccb6cadb985d3...
Or simply recompile the kernel for 4k pages :)
https://bugs.winehq.org/show_bug.cgi?id=52715
Teoh Han Hui teohhanhui@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |teohhanhui@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=52715
Neko-san nekoNexus@protonmail.ch changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nekoNexus@protonmail.ch
https://bugs.winehq.org/show_bug.cgi?id=52715
dofficialgman@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dofficialgman@gmail.com
--- Comment #5 from dofficialgman@gmail.com --- Hi,
Raspberry pi 5 will release in about a month and the pi foundation is experimenting with using 16K pages by default.
https://github.com/geerlingguy/sbc-reviews/issues/21#issuecomment-1740279618
It would be great if this issue could be fixed before that device releases and users start submitting bug reports.
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #6 from Austin English austinenglish@gmail.com --- Created attachment 75212 --> https://bugs.winehq.org/attachment.cgi?id=75212 use 16k stack size on aarch64
I tried forcing 16k, which didn't improve the situation. Attaching the patch for reference.
https://bugs.winehq.org/show_bug.cgi?id=52715
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #75212|use 16k stack size on |use 16k page size on description|aarch64 |aarch64
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #7 from Austin English austinenglish@gmail.com --- Created attachment 75213 --> https://bugs.winehq.org/attachment.cgi?id=75213 try 64k pages
64k doesn't work either
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #8 from Fabian Maurer dark.shadow4@web.de --- Created attachment 75726 --> https://bugs.winehq.org/attachment.cgi?id=75726 16k page hacks
Attaching the hacks I used to get 16k pages working.
Environment: - Asahi Linux Fedora on M1 Mac Mini - llvm-mingw-20231128
You'll also need to set 16k pages for the PE binaries: export CROSSLDFLAGS="-Wl,-section-alignment=16384"
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #9 from Fabian Maurer dark.shadow4@web.de --- *** Bug 52934 has been marked as a duplicate of this bug. ***
https://bugs.winehq.org/show_bug.cgi?id=52715
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|wine segfaults on asahi |wine segfaults on asahi |linux (apple M1 hardware, |linux due to 16k pages |linux kernel/userland) |(apple M1 hardware, linux | |kernel/userland)
--- Comment #10 from Fabian Maurer dark.shadow4@web.de --- I'll work on a less hacky solution soon.
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #11 from Austin English austinenglish@gmail.com --- (In reply to Fabian Maurer from comment #8)
Created attachment 75726 [details] 16k page hacks
Attaching the hacks I used to get 16k pages working.
Environment:
- Asahi Linux Fedora on M1 Mac Mini
- llvm-mingw-20231128
You'll also need to set 16k pages for the PE binaries: export CROSSLDFLAGS="-Wl,-section-alignment=16384"
Thanks. These also work for me using debian on m1.
FWIW, I tried winetest afterward: 72 failures (a significant number of those are related to missing gecko/mono, bug 43938).
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #12 from Fabian Maurer dark.shadow4@web.de --- Created attachment 76032 --> https://bugs.winehq.org/attachment.cgi?id=76032 updated 64k hack
Attaching an updated minimal 64k pages hack. You also need to revert 0900d919e2fd5ce12e02375cfcbfa5ab7c283515 otherwise it just hangs.
Alexandre said Wine must be able to load 4k binaries so that part of the hack will never be accepted. Currently no idea how to do that though.
https://bugs.winehq.org/show_bug.cgi?id=52715
m1m1k4tz m1m1k4tz@protonmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |m1m1k4tz@protonmail.com
--- Comment #13 from m1m1k4tz m1m1k4tz@protonmail.com --- A way to get this working with good performance could be to use box64 and drm native context but that throws an error the last time I tested it out. It could be different but I would have to reinstall Asahi linux and I'm probably just gonna wait until it has Vulkan support so there's a chance for decent performance with the new wow64 mode. It might work with FEX Emu but I haven't tested it out so it could just be an error with box64 https://sinrega.org/2023-10-06-using-microvms-for-gaming-on-fedora-asahi/
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #14 from m1m1k4tz m1m1k4tz@protonmail.com --- Created attachment 76099 --> https://bugs.winehq.org/attachment.cgi?id=76099 krunvm
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #15 from Fabian Maurer dark.shadow4@web.de --- While that might work, I think Wine should also be able to support 16k pages natively. Not sure if there's anything that would prevent this from working, but it certainly isn't easy. Especially since there is probably more than one way it could be approached. If only a knew the exe format and the wine loader code better...
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #16 from m1m1k4tz m1m1k4tz@protonmail.com --- That's true and it would make my life a lot easier instead of trying to track down what bug it is in 3 different pieces of software lol
https://bugs.winehq.org/show_bug.cgi?id=52715
--- Comment #17 from Fabian Maurer dark.shadow4@web.de --- Note: For testing you need to run autoreconf after applying the patch (I tend to forget that part)
Hack still works, and you still need to revert 0900d919e2fd5ce12e02375cfcbfa5ab7c283515
https://bugs.winehq.org/show_bug.cgi?id=52715
Tomáš Bžatek bugs@bzatek.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bugs@bzatek.net
https://bugs.winehq.org/show_bug.cgi?id=52715
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |cdfrosty@gmail.com
--- Comment #18 from Fabian Maurer dark.shadow4@web.de --- *** Bug 57417 has been marked as a duplicate of this bug. ***