[Bug] LATX_MT=1/2 aborts immediately on x86_64 (itemp register exhausted, SIGTRAP)

Closed Beginner friendly
#524 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

A pull request for this has already been merged.

  • #525 by @xiezyang — merged

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Start in target/i386/latx/translator/translate.c, at gen_test_page_flag(), and check where the itemp allocations sit relative to the TARGET_ABI_BITS guard. Then inspect ra_alloc_itemp() in target/i386/latx/translator/reg-alloc.c to understand the abort under register pressure. Reproduce with LATX_MT=1 or LATX_MT=2 on a 16KB-page LoongArch64 host; done means startup no longer aborts on the x86_64 target.

Written by the indexing model from the issue text.

Description

On a 16KB-page LoongArch64 host, setting LATX_MT=1 or LATX_MT=2 for the x86_64 translator aborts at startup:

[LATX] itemp register exhausted, status=0x7f
SIGTRAP (core dumped)

The option is accepted because it only checks qemu_real_host_page_size == 16K, which holds on this host — but the code it enables is not compiled for the 64-bit target.

Two things combine (line numbers at master 48a9c55):

  1. target/i386/latx/translator/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 on every memory access, while the 16K body that was meant to consume them is not compiled in.
  2. target/i386/latx/translator/reg-alloc.c:295-310 makes ra_alloc_itemp() abort() when the pool is exhausted, so the graceful fallback immediately below it (translate.c:4584-4596, spilling into a0/a1/a2 via need_restore0/1/2) can never run — it is dead code under register pressure.

Suggested fix (either one):

  • move the three itemp allocations inside the #if TARGET_ABI_BITS == 32 guard, or
  • reject LATX_MT at option-parse time when TARGET_ABI_BITS == 64, with a clear message.

Environment

  • Host CPU: Loongson 3A6000 (LoongArch64)
  • OS: Galaxy Kylin V10 SP1 2503, kernel 5.4.18-125-generic
  • Host page size: 16KB (CONFIG_PAGE_SIZE_16KB=y)
  • Reproduced with both distro package lat 1.6.7 and locally built master 48a9c55
  • getconf PAGESIZE -> 16384

Reproduce

LATX_MT=1 latx-x86_64 /opt/wine-stable/bin/wine64 'C:/npp/notepad++.exe'
LATX_MT=2 latx-x86_64 /opt/wine-stable/bin/wine64 'C:/npp/notepad++.exe'

Both abort immediately with the message above.

Happy to run any patch you suggest — this is a dedicated test box.

Dominant language
C
Stars
246
Forks
64
Avg merge
2d 19h
Merged PRs (30d)
24

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lat-opensource/lat

All issues in lat-opensource/lat

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.