ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.73k stars 267 forks source link

Didn't detect 48bits of address space, considering it's 39bits #1365

Closed ForeverFirstDay closed 6 months ago

ForeverFirstDay commented 6 months ago

I use the latest box64 and wine64-stable-9.0.0.0. I meet with the following errs whenever a 64bit app installing. And the installer stuck anyway.

Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 PageSize:4096 Running on Unknown CPU with 8 Cores
Will use Hardware counter measured at 62.5 MHz emulating 500 MHz
Params database has 61 entries
Box64 with Dynarec v0.2.7 cd8bda7a built on Mar 15 2024 17:19:32
BOX64: Wine64 detected, WINEPRELOADRESERVE="000400000-0004b9000"
BOX64: Detected running wine with "dbeaver-ce-23.1.3-x86_64-setup.exe"
BOX64: Didn't detect 48bits of address space, considering it's 39bits
Counted 49 Env var
BOX64 LIB PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/:/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/
BOX64 BIN PATH: ./:bin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/:/usr/games/:/usr/local/games/
Looking for /home/gyy/wine/bin/wine64
Apply RC params for wine64
Applying BOX64_MAXCPU=64
argv[1]="Z:\home\gyy\dbeaver-ce-23.1.3-x86_64-setup.exe"
Rename process to "wine64"
Using native(wrapped) libdl.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) librt.so.1
Using native(wrapped) libbsd.so.0
Using emulated /home/gyy/wine/bin/../lib64/wine/x86_64-unix/ntdll.so
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
0100:err:environ:init_peb starting L"Z:\\home\\gyy\\dbeaver-ce-23.1.3-x86_64-setup.exe" in experimental wow64 mode
0100:err:virtual:map_fixed_area out of memory for 0x6fffffc20000-0x6ffffffec000
0100:err:virtual:try_map_free_area mmap() error, can not malloc memory, range 0x7fffffc20000-0x7ffffffec000, unix_prot 0x7.
wine: failed to load L"\\??\\C:\\windows\\syswow64\\ntdll.dll" error c000013
Unable to start the program, or there is no application associated with the specified file.
ShellExecuteEx error

However, wine64 notepad work well with the similar errs.

Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 PageSize:4096 Running on Unknown CPU with 8 Cores
Will use Hardware counter measured at 62.5 MHz emulating 500 MHz
Params database has 61 entries
Box64 with Dynarec v0.2.7 cd8bda7a built on Mar 15 2024 17:19:32
BOX64: Didn't detect 48bits of address space, considering it's 39bits
Counted 37 Env var
BOX64 LIB PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/:/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/
BOX64 BIN PATH: ./:bin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/:/usr/games/:/usr/local/games/
Looking for /home/gyy/wine/bin/wineserver
Rename process to "wineserver"
Using native(wrapped) libdl.so.2
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libutil.so.1
Using native(wrapped) librt.so.1
Using native(wrapped) libbsd.so.0
Using emulated /home/gyy/wine/bin/../lib64/wine/x86_64-unix/ntdll.so
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
002c:err:virtual:map_fixed_area out of memory for 0x6fffffc20000-0x6ffffffec000
002c:err:virtual:try_map_free_area mmap() error, can not malloc memory, range 0x7fffffc20000-0x7ffffffec000, unix_prot 0x7.
...
...
0050:err:ole:start_rpcss Failed to start Rpc5s service
00cc:err:virtual:map_fixed_area out of memory for 0x6fffffc20000-0x6ffffffec000
00cc:err:virtual:try_map_free_area mmap() error, can not malloc memory, range 0x7fffffc20000-0x7ffffffec000, unix_prot 0x7.
...
Using emulated /home/gyy/wine/lib64/wine/x86_64-unix/win32u.so
Using native(wrapped) libm.so.6
Using native(wrapped) libfreetype.so.6
Using native(wrapped) libfontconfig.so.1
Using native(wrapped) libexpat.so.1
Using emulated /home/gyy/wine/lib64/wine/x86_64-unix/winex11.so
Using native(wrapped) libXext.so.6
Using native(wrapped) libX11.so.6
Using native(wrapped) libxcb.so.1
Using native(wrapped) libXau.so.6
Using native(wrapped) libXdmcp.so.6
Using emulated /home/gyy/wine/lib64/wine/x86_64-unix/winex11.so
Using emulated /home/gyy/wine/lib64/wine/x86_64-unix/winspool.so
Using native(wrapped) libcups.so.2
ptitSeb commented 6 months ago

Well, the error you have are wine error. It bascically complains because you have 39 bits of address space only, like box64 warns you. I'm unclear if those error are fatal or if wine tries again in anouther area. If you want the error to go away, you need to patch Wine at the source level, tere is nothing box64 can do here.

The setup freezing might be because it needs to be run with BOX64_DYNAREC_SAFEFLAGS=2 and/or BOX64_DYNAREC_STRONGMEM=1

theofficialgman commented 6 months ago

I'm unclear if those error are fatal or if wine tries again in anouther area. If you want the error to go away, you need to patch Wine at the source level, tere is nothing box64 can do here.

as I mentioned before, its a result of this change https://gitlab.winehq.org/wine/wine/-/commit/30c8da1c9dd8dcc1aee2d328a5fdf7edbf6c7978

I don't really know what the change was addressing or why it was changed since the commit message provides no meaningful information to me and there is no linked issue.

ForeverFirstDay commented 6 months ago

Thank you very much for your replies. I will publish this issue on winehq.org later.

theofficialgman commented 2 months ago

upstream configuration issue (for raspberry piOS, contact your distro maintainer for other hardware and systems) https://github.com/raspberrypi/linux/issues/6261

theofficialgman commented 2 months ago

I have gone ahead and asked for some explanation here from wine https://gitlab.winehq.org/wine/wine/-/merge_requests/3598#note_75871

theofficialgman commented 2 months ago

Resolved with pi-apps wine build https://github.com/Pi-Apps-Coders/files/commit/d4e9180610689f09e65a8fa88121a339bce1745a

Consider adding the same patch if you build wine from source

theofficialgman commented 4 weeks ago

This is now resolved in upstream wine master

ptitSeb commented 4 weeks ago

Oh, that's sa good news! So it's fixed with wine9.16+?

theofficialgman commented 4 weeks ago

Not yet. Next unreleased version will include it

ptitSeb commented 4 weeks ago

Not yet. Next unreleased version will include it

Thanks for the info :)

RandyR99 commented 2 weeks ago

@theofficialgman @ptitSeb Still seeing virtual memory allocation errors using Wine 9.17. I was hoping the fix would have made that release. This is on a Pi5 with kernel8.img:

002c:err:virtual:try_map_free_area mmap() error Cannot allocate memory, range 0x7fffb30000-0x7fffcbd000, unix_prot 0x7. 002c:err:virtual:try_map_free_area mmap() error Cannot allocate memory, range 0x7fff750000-0x7fffcb5000, unix_prot 0x7.

theofficialgman commented 2 weeks ago

@theofficialgman @ptitSeb Still seeing virtual memory allocation errors using Wine 9.17. I was hoping the fix would have made that release. This is on a Pi5 with kernel8.img:

002c:err:virtual:try_map_free_area mmap() error Cannot allocate memory, range 0x7fffb30000-0x7fffcbd000, unix_prot 0x7. 002c:err:virtual:try_map_free_area mmap() error Cannot allocate memory, range 0x7fff750000-0x7fffcb5000, unix_prot 0x7.

@RandyR99 please provide a full log as well as the binary executable you are running. the issue is resolved and included in Wine 9.17 and I am unable to reproduce it occurring anymore in my test programs.

If you run WINEDBG=+virtual wine programname you will see (similar to) the following output which shows it detected the max address space available for the system

trace:virtual:virtual_init host addr space limit: 0x7fffff0000
theofficialgman commented 2 weeks ago

002c:err:virtual:try_map_free_area mmap() error Cannot allocate memory, range 0x7fffb30000-0x7fffcbd000, unix_prot 0x7. 002c:err:virtual:try_map_free_area mmap() error Cannot allocate memory, range 0x7fff750000-0x7fffcb5000, unix_prot 0x7.

these are values below 39bits I think and likely indicate wine tried to allocate memory in an area of ram that does exist but is not available (eg: due to a carveout by another process). that is unrelated and the issue where wine tried to allocate memory in an area above the address space maximum is fixed.

RandyR99 commented 2 weeks ago

Ahh, I didn't look closely at the address. I should point out that when using a custom kernel with 48-bit virtual addressing I don't see any memory allocation errors. However it is not as up-to-date (it was built on 29 Apr 2024) as the latest kernel. I tried to attach the file but it is too big. Here is a link to the archive containing the file. It is the chess engine stockfish 16 (30 June 2023) run from the command line. Let me know if you still want logs.

RandyR99 commented 2 weeks ago

I moved the SD card to a Pi4-8Gb to test and did not see the errors. When I moved it back to the Pi5-8Gb, the errors no longer appeared. Happy but baffled. Sorry for wasting anyone's time. Thanks for everyone's work on Box and Wine.