Repository navigation
Generalize emutls corruption fix beyond v1.26.0.2 - #141
trasnake87 wants to merge 1 commit into
Conversation
PR minecraft-linux#132 fixed one specific __emutls_control corruption offset for v1.26.0.2 where __emutls_v.* symbols collided with rand_meth data due to an LLD linker bug. Newer Bedrock releases (1.26.10.x, 1.26.20.x, 1.26.30.x and onward) all hit the same bug class but at different, release-specific offsets — hand-finding each one by disassembly has not scaled. Add a runtime function hook on __emutls_get_address in libc++_shared.so (the only implementation libminecraftpe.so imports) that sanitizes the incoming control struct when it detects the collision pattern (size and align both pointer-sized — > 256MB) and resets to the safe defaults {size=8, align=8, index=0, templ=NULL} before tail-calling the original. The hook patches the function entry with a 13-byte absolute jump (`movabs $wrapper, %r11; jmp *%r11`) and trampolines the original 16 bytes (libc++_shared's prologue: 6× push, mov %rdi,%rbx, mov 0x10(%rdi), %r13 — falls exactly on instruction boundaries). 13-byte trampolines break here because they cut the trailing 4-byte mov in half. Also stub Java_com_mojang_minecraftpe_PlayIntegrity_nativePlayIntegrityComplete in the JNI symbol resolver — 1.26.20.4 expects the native to exist but no shipped library exports it, and Google Play Integrity has no Linux desktop equivalent. A no-op stub silences the missing-symbol log; the underlying integrity check is launcher-stubbed already (MainActivity::startPlayIntegrityCheck is empty). Tested on 1.26.20.4 — game boots through static init past the previous SIGABRT in MinecraftGame::init and reaches the main menu. Existing v1.26.0.2 direct-offset patch is left in place for backward compat. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The three failing Linux jobs ( The Bookworm jobs that actually exercise this change build cleanly across all four architectures ( |
Background
PR #132 fixed one specific
__emutls_controlcorruption offset for v1.26.0.2 where__emutls_v.*symbols collided withrand_methdata due to an LLD linker bug. The same bug class hits later Bedrock releases (1.26.10.x, 1.26.20.x, 1.26.30.x, …) but at different release-specific offsets, and the bad controls vary per point release. Hand-finding each one by disassembly hasn't scaled — every new build crashes again withSIGABRT600+ frames deep in static init viaMinecraftGame::init.What this PR does
Adds a runtime function hook on
__emutls_get_addressinlibc++_shared.so(the only implementationlibminecraftpe.soimports). The wrapper sanitizes any control whose first two fields (size, align) are both pointer-sized (≥ 256MB) — that's the collision pattern; real controls havesize < 1MBandalign ≤ 4096— and resets to{size=8, align=8, index=0, templ=NULL}before tail-calling the original. Catches every version of the bug at runtime, no per-build offset hunting.The hook patches the function entry with a 13-byte absolute jump (
movabs \$wrapper, %r11; jmp *%r11) and trampolines the original 16 bytes. libc++_shared's__emutls_get_addressprologue is 6× push,mov %rdi,%rbx,mov 0x10(%rdi),%r13— exactly 16 bytes ending on an instruction boundary. A 13-byte trampoline copy would cut the trailing 4-byte mov in half and break the trampoline.Also stubs
Java_com_mojang_minecraftpe_PlayIntegrity_nativePlayIntegrityCompletein the JNI symbol resolver — 1.26.20.4 declares the native but no shipped library exports the C side. Google Play Integrity has no Linux desktop equivalent, the underlyingMainActivity::startPlayIntegrityCheckis already a no-op, and a no-op stub here silences the missing-symbol log without changing behavior.Tested
Notes
#ifdef __x86_64__).size ≥ 256MB && align ≥ 256MBis intentionally strict — false positives would catch any pair of pointers, but no real__emutls_get_addresscall would ever pass through such a control (real ones have small-integer size/align).🤖 Generated with Claude Code