Skip to content

LATX, fix: Clear zero absolute LEA destinations - #387

Merged
LaurenIsACoder merged 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:lauren/issue-373-apt-segv
Aug 11, 2026
Merged

LaurenIsACoder merged 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:lauren/issue-373-apt-segv

Conversation

@LaurenIsACoder

@LaurenIsACoder LaurenIsACoder commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

While looking into #373, I found a concrete i386 LEA translation bug on current master.

convert_mem_helper() returned zero_ir2_opnd immediately for an address with no base, index, segment, or displacement. That works for callers that consume the returned operand, but convert_mem_to_specific_gpr() passes a destination register and discards the return value. For lea edi,[0], EDI was therefore left unchanged. In apt this stale value corrupted the following TLS address calculation and caused a SIGSEGV.

This change keeps the existing early return for ordinary address conversion, but lets the specific-register path continue through adjust_dest() so the zero is actually written. The old assertion is replaced with one that documents this path.

Validation:

  • focused lea edi,[0] check: exit 1 with the fix hunk reversed, exit 0 with it restored
  • i386 apt-get --version: exit 0 with LATX_AOT=0 LATX_TU=0
  • i386 apt-get --version: exit 0 with default translation settings
  • i386 translator build: pass

Every guest run invoked latx-i386 explicitly. The binfmt registration was not used or modified, and the tested apt command did not enter guest fork/exec paths.

The reproduced symptom was a deterministic SIGSEGV, not the timeout reported in #373, so this PR is related to that investigation but does not close the issue by itself. The original reproducer still needs to be retested.

convert_mem_helper returned the zero operand before writing it to a caller-supplied destination register. As a result, an i386 LEA with no base, index, segment, or displacement left the destination unchanged and corrupted local-dynamic TLS address calculations.

Signed-off-by: Hanlu Li <[email protected]>
@LaurenIsACoder
LaurenIsACoder marked this pull request as ready for review August 11, 2026 02:22
@LaurenIsACoder
LaurenIsACoder merged commit 5180977 into lat-opensource:master Aug 11, 2026
20 checks passed
@LaurenIsACoder
LaurenIsACoder deleted the lauren/issue-373-apt-segv branch August 11, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant