Skip to content

[Bug] 16KB-page host: 64-bit Wine GUI apps never map their window (futex/pipe hang); same host with the i386 translator is fine #523

Open

Description

@kong5021

Summary

On a LoongArch64 host with 16KB pages, the x86_64 translator cannot run complex multi-threaded Windows GUI applications: the top-level window is created but never mapped and the main thread parks in futex_wait forever. The i386 translator on the same host, same Wine prefix and same Wine build runs the same applications perfectly.

While narrowing this down I found that the 16KB mixed-page compensation (latx_4k_page_flags, latx_16k_page_mixed, option_minke_16k_page_check, and the 16K branch added by #520) is compile-time gated to TARGET_ABI_BITS == 32, so the x86_64 target has no 16KB-page bookkeeping at all. I'd like to confirm whether that is the expected state and whether 64-bit 16KB support is planned.

Environment

All source line numbers below refer to upstream master 48a9c55.

$ uname -a
Linux user-pc 5.4.18-125-generic #114oemlx10u SMP Mon Oct 14 08:20:59 UTC 2024 loongarch64 loongarch64 loongarch64 GNU/Linux

$ getconf PAGESIZE
16384
Item Value
Host CPU Loongson 3A6000 (LoongArch64), 8 cores
OS Galaxy Kylin V10 SP1 2503, kernel 5.4.18-125-generic
Host page size 16KB (CONFIG_PAGE_SIZE_16KB=y)
LATX (A) distro package lat 1.6.7
LATX (B) master 48a9c55 (2026-10-21, contains #515 and #520), built locally with latxbuild/build-release.sh, version string lat-x86_64 48a9c55
Wine 10.0, WoW64 layout (bin/wine64 = x86-64, bin/wine = i386)
Display Xvfb 1280x800x24 + openbox 3.6.1 (identical on a real Xorg display)
User VA CONFIG_VA_BITS_40=y (1 TB user address space). Listed for completeness: simple 64-bit apps do run, so we do not believe this is the cause.

Symptom

64-bit Windows GUI applications create a top-level window that is never mapped:

  • Notepad++ 8.6.9 (PE32+ x86-64): window created as 115x1, Map State: IsUnMapped, process alive, no error output. Main thread blocked in futex_wait_queue_me (FUTEX_WAIT_PRIVATE, val=2); a second thread sits in pipe_read.
  • 7-Zip 24.08 7zFM.exe (x64) and SumatraPDF 3.5.2 (x64): same signature (2× futex_wait + 1× pipe_read).
  • Wine builtin notepad.exe (64-bit): window geometry is correct (752x536) but IsUnMapped; single thread in pipe_wait; screen stays blank before and after a click.

Screenshots of the root window are 279 bytes (single flat colour), i.e. nothing is rendered.

Control: the 32-bit path is healthy on the same host

App Bitness Result
7-Zip 24.08 7zFM.exe 32-bit IsViewable, full UI, menus open
Notepad++ 8.6.9 32-bit IsViewable 1092x666, File menu drops down
winemine 32-bit IsViewable, Chinese menu, grid rendered
7z.exe CLI (add + extract) 32-bit Everything is Ok both directions
VLC 3.0.24 32-bit window IsViewable, plays a local mp4, timer advances
winecfg 64-bit renders fine (single-threaded GUI)
clock, regedit 64-bit IsViewable

So the failure is specific to complex, multi-threaded 64-bit guests on a 16KB-page host; 64-bit single-threaded GUIs and the whole 32-bit path are fine.

Source-level observation: 16KB mixed-page handling is 32-bit only

Everything that tracks the host-16K / guest-4K permission mismatch is compiled out for x86_64:

  • include/exec/cpu-all.h:246-256 — latx_4k_page_flags, latx_16k_page_mixed and the whole declaration block sit inside #if TARGET_ABI_BITS == 32. (Understandable, since LATX_GUEST_PAGE_COUNT is 1U << (TARGET_ABI_BITS - TARGET_PAGE_BITS), which is not usable for a 64-bit address space — but that means there is no sparse 64-bit equivalent either.)
  • accel/tcg/translate-all.c:3124 — the definition of latx_4k_page_flags / latx_16k_page_mixed / latx_init_16k_page_checks() / latx_update_page_permissions() is under the same TARGET_ABI_BITS == 32 guard.
  • linux-user/main.c:1564-1581 — both latx_init_16k_page_checks() and the Minke check setup are inside #if ... TARGET_ABI_BITS == 32; and handle_arg_latx_minke_16k_page_check() at main.c:866-870 explicitly forces the option back to 0 in the 64-bit branch.
  • target/i386/latx/translator/translate.c:4602 — the 16KB branch in gen_test_page_flag() (the code introduced by LATX, opt: Check guest permissions before mixed host-page fallback #520) is itself inside #if TARGET_ABI_BITS == 32, so it cannot apply to the x86_64 translator.

That would explain why #515/#520 changed nothing here: on this host the x86_64 target still performs no per-4K-page permission bookkeeping, so a guest 4K page sharing a host 16K page with different-permission neighbours can be over-protected (a legitimate guest write faults) or under-protected. We have not proven that this is what causes the futex/pipe hang. We are reporting the structural absence of bookkeeping and asking whether the hang is its expected consequence. One data point makes us unsure: we observe no SIGSEGV anywhere in the logs, which is what naive over-protection would normally produce.

LATX_MT cannot be used as a workaround on x86_64

LATX_MT=1 and LATX_MT=2 are accepted on the 64-bit binary (the option only checks qemu_real_host_page_size == 16K, which holds), but both abort immediately with

[LATX] itemp register exhausted, status=0x7f

and die with SIGTRAP (core dumped). Two things seem to combine here:

  1. translate.c:4581-4583 allocates three itemps at the top of gen_test_page_flag(), before the #if TARGET_ABI_BITS == 32 guard at 4602 — on a 64-bit build the allocation happens for every memory access while the 16K body that was supposed to consume them is not compiled in.
  2. reg-alloc.c:295-310 makes ra_alloc_itemp() abort() when the pool is exhausted, so the graceful fallback right below it (translate.c:4584-4596, spilling into a0/a1/a2 via need_restore0/1/2) can never run — it is dead code whenever the allocator is under pressure.

So LATX_MT is currently a landmine on x86_64 rather than a diagnostic.

Already ruled out

  • CPU pinning: taskset -c 0, -c 1, -c 2, -c 0-3, and no pinning at all — identical hang.
  • Translator version: 1.6.4, 1.6.7 (distro), master 48a9c55 built locally — identical hang.
  • LATX_CLOSE_PARALLEL=1 — no change.
  • wineserver — healthy, idle in do_epoll_wait.
  • Display stack — Xvfb without WM, Xvfb + openbox, real Xorg :0 — identical.
  • Guest program — reproduced with Wine's own 64-bit notepad.exe, so it is not specific to any third-party app.

Reproduce (minimal)

# 16KB-page LoongArch host, binfmt_misc x86_64 -> latx-x86_64
export WINEPREFIX=/data/latx-wine/default WINEARCH=win64
export LAT_LD_PREFIX=/opt/latx-wine/rootfs2
latx-x86_64 /opt/wine-stable/bin/wine64 'C:/npp/notepad++.exe'

# observe
xwininfo -root -tree | grep -i notepad     # 115x1, IsUnMapped
for t in /proc/<pid>/task/*; do cat $t/wchan; done
#  -> futex_wait_queue_me   (main thread)
#  -> pipe_wait

Questions

  1. Is the absence of any 16KB mixed-page bookkeeping on the x86_64 target intentional/known, or is a 64-bit (sparse) variant planned? If it is known, is the futex/pipe hang the expected consequence on 16K hosts?
  2. Should LATX_MT be rejected (or the itemp allocations moved inside the 32-bit guard) on x86_64, given it currently aborts at startup?
  3. Is there a quick way for us to validate the hypothesis — for example a debug-only switch that enables 16K-page bookkeeping on the x86_64 target, even with a slow or sparse implementation where performance does not matter? We only need to know whether the hang disappears when bookkeeping is present.

I can provide per-thread wchan dumps, core files, or run any patch you suggest on this machine — it is a dedicated test box and we can iterate quickly.

Activity

  1. kong5021 commented on Oct 26, 2026

    @kong5021
    Author

    Correction: 16KB page size is not the differentiator - new suspect is 699471d

    We opened this report blaming the 16KB host page size for the x86_64
    futex/pipe hang. We now have direct evidence against that. Posting the
    correction here instead of opening a new issue.

    1. Page size is ruled out

    Two machines, same CPU (Loongson 3A6000-HV), same 16KB page size, opposite
    results:

    Kylin V10 SP1 (fails) UOS / deepin (works)
    kernel 5.4.18-125 4.19.0-loongson-3
    lat 1.6.7 1.6.4 (1.6.4deepin1) [1]
    Wine self-built 10.0 (WoW64) deepin-wine10-stable, Wine 10.14
    x86_64 GUI hangs: IsUnMapped, works: notepad / winecfg /
    futex_wait + pipe_wait regedit all IsViewable

    PAGESIZE is 16384 on both machines. The page size cannot be the
    differentiator.

    [1] 1.6.4deepin1 is a packaging-only rebuild. The Debian changelog shows no
    source changes to the translator, so it behaves as stock upstream 1.6.4.

    2. The 16K code path is not even running

    Our earlier source-level claim was also wrong. The 16K mechanism
    (pageflags_root interval tree plus option_mem_test) is not guarded by
    TARGET_ABI_BITS, and option_mem_test is off unless LATX_MT is set. It is
    therefore not active during the failing runs. The 16K path is a red herring
    here.

    3. New suspect: commit 699471d

    That commit rewrote gen_test_page_flag(). Before: three fixed registers
    a0/a1/a7. After: three ra_alloc_itemp() calls plus a need_restore fallback.

    Two things matter:

    (a) ra_alloc_itemp() aborts instead of returning failure:

          if (unlikely(itemp_reg_num < 0)) {
              fprintf(stderr, "[LATX] itemp register exhausted, status=0x%x\n",
                      lsenv->tr_data->itemp_status);
              abort();
          }
    
      so the need_restore fallback is dead code - it can never be reached.
    

    (b) the x86_64 itemp pool has only 7 entries:

          reg_itemp_map[] = { t0, t1, t2, t3, t4, la_ra, la_a7 }   /* x86_64 */
    
      while i386 has 11 (adds t5..t8, ra, a7). With option_mem_test on, this
      allocator is hit on every memory access, so 7 slots are not enough.
    

    4. The log matches bit for bit

    The failing Kylin logs contain:

    [LATX] itemp register exhausted, status=0x7f

    itemp_status is a bitmask of the pool. 0x7f == 0b1111111 - exactly 7 bits,
    all set. That is precisely the x86_64 pool size, fully exhausted. An i386
    build with 11 slots could never print 0x7f.

    5. Reverse test on 1.6.4

    To confirm that the version is what matters, we forced the trigger on the
    machine that works - LATX_MT=1 with Wine 10.14 under lat 1.6.4 - and the
    64-bit GUI still came up fine, all windows IsViewable. 1.6.4 walks the same
    path with fixed registers, so it is immune. This is consistent with
    699471d being the regression point.

    6. What we have NOT isolated yet

    To be clear, this is a strong suspicion, not a proven root cause. Three
    variables are still open:

    • whether the Kylin /usr/bin/wine-x64 wrapper injects LATX_MT
    • Wine 10.0 (self-built WoW64) vs Wine 10.14 (deepin)
    • kernel 5.4.18-125 vs 4.19.0-loongson-3

    The Kylin machine is currently down (a newer kernel fails to boot) and we
    will report back once it is up again.

    7. Questions for upstream

    1. Is LATX_MT / option_mem_test meant to be usable on the x86_64 target at
      all, or is it effectively i386-only?
    2. With only 7 itemp registers on x86_64, should gen_test_page_flag() bail
      out early when TARGET_ABI_BITS == 64? The companion patch in issue [Bug] LATX_MT=1/2 aborts immediately on x86_64 (itemp register exhausted, SIGTRAP) #524
      proposes exactly that, and we believe it is still worth merging as a
      defensive fix.
    3. Is the need_restore branch in gen_test_page_flag() dead code by design,
      given that ra_alloc_itemp() aborts rather than returning an error?
  2. xiangzhai commented on Oct 26, 2026

    @xiangzhai
    Contributor

    Hi,

    Not reproduced:

    Image
    $ uname -a
    Linux aosc-3a6000 7.1.13-aosc-main-16k #1 SMP PREEMPT_DYNAMIC Mon Sep  7 10:59:10 UTC 2026 loongarch64 GNU/Linux
    
    $ ./latx-x86_64 --version
    lat-x86_64 1.6.5-529-g48a9c55d92
    
    $ ps aux |grep notepad
    zhaixia+  148726 10.6 20.7 470911392 6890096 pts/0 S+ 10:34   0:14 /home/zhaixiang/latx-x86_64 /usr/lib/wine/x86_64-unix/wine-preloader /usr/lib/wine/x86_64-unix/wine ./wine-11.20-staging-tkg-amd64-wow64/lib/wine/x86_64-windows/notepad.exe
    

    https://github.com/Kron4ek/Wine-Builds/releases/download/11.20/wine-11.20-staging-tkg-amd64-wow64.tar.xz

    $ file ./wine-11.20-staging-tkg-amd64-wow64/lib/wine/x86_64-windows/notepad.exe
    ./wine-11.20-staging-tkg-amd64-wow64/lib/wine/x86_64-windows/notepad.exe: PE32+ executable for WINE (GUI), x86-64 (stripped to external PDB), 11 sections
    

    Thanks,
    Leslie Zhai

  3. kong5021 commented on Oct 26, 2026

    @kong5021
    Author

    Final update: you are right - this was a corrupted WINEPREFIX, not lat @//xiangzhai/ Thank you for taking the time to test this. Your "not reproduced"

    result is correct, and we can now explain exactly why: the bug was never in
    lat. It was in our WINEPREFIX.
    We owe you an apology. Our first comment blamed 699471d / itemp exhaustion.
    That was wrong - the "itemp register exhausted, status=0x7f" message came from
    our own LATX_MT=1 experiment, not from the failing runs. We then chased a
    second theory (16KB host page size, and host-page alignment in Wine's ntdll).
    That was also wrong. We should have run a cross-variable experiment first.
    Here it is. Same machine throughout - Kylin V10 SP1, kernel 5.4.18-125, 16KB
    page size, lat 1.6.7, Loongson 3A6000-HV - two Wine builds crossed with two
    prefixes:

    Wine build old WINEPREFIX fresh WINEPREFIX
    self-built 10.0 hang: futex_wait_queue_me works
    deepin 10.14 hang: futex_wait_queue_me works
    Only the prefix matters; the Wine build does not. All four cells ran under the
    same lat 1.6.7, so lat is not involved. Note also that the self-built Wine 10.0
    works fine on this same 16KB-page host once the prefix is clean, which rules
    out the page-size theory too. Your test used wine-11.20 and ours is 10.0, so
    the "works" result is not specific to one Wine version either.
    What actually went wrong: our old WINEPREFIX was corrupted. ~/.bash_history
    shows 15+ pkill -9 wineserver and pkill -9 -f wine64 invocations from
    earlier debugging sessions. Registry changes live in the wineserver process and
    are flushed to disk on a clean exit, so SIGKILL loses them or leaves them
    half-written. That is almost certainly how the prefix got damaged. With a clean
    prefix, notepad / winecfg / regedit all come up normally again.
    The try_map_free_area() mmap EINVAL messages we quoted earlier were a symptom
    of the damaged prefix, not a cause.
    Conclusion: nothing to fix in lat. Please feel free to close this issue, and
    sorry again for the noise.
    Note: issue #524 is independent of this hang. It is a separate robustness
    observation (the x86_64 target has only 7 itemp registers) and still stands on
    its own.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions