Treat a target below 4 GiB behind the optional reference at object +0x6b0 as absent, so the freed-holder crash in main+0x1bd0138 stops on 1.4.3 and 1.2.1 (#1005)

The holder of the PlayerVirtualKey request can be freed while the request still points at it; its first word then reads
as a small number and the game dereferences it as the target actor. No guest object lives below 2^32, so such a target
now takes the game's own branch for a null target. Same TOTK_OPTREF_GUARD switch as the existing optref site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-12 07:47:32 +03:00
1 parent d8a1d14104
commit b80a568df5
3 files changed
+12 -1

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ GPU semantics behind the graphics rows: [maxwell.md](../maxwell.md). The method
| a host core at 100% while the game waits | game spin loops without system calls | profile: which guest function spins |
| crash on world load | sizes the game reads from the driver (command memory used) differ from the console's | the sizes the game asks for against the console's |
| crash with one save only | the save itself; some crash on a real Switch | the same save on another build and, if possible, on hardware |
| random crash after minutes to hours, access violation reading `0xffffffffffffffff` in a game function | an invalid value (-1, `0xffff0000ffffffff`) in an optional reference the game checks only for null; set `optref` in `recomp/patches-v143.txt` guards main+0x1bd0138 | the crash dump's faulting host instruction, the register it loads through and the field that register came from |
| random crash after minutes to hours, access violation reading `0xffffffffffffffff` or a small address such as `0x90` in a game function | an invalid value (-1, `0xffff0000ffffffff`) in an optional reference the game checks only for null, or a freed holder whose first word reads as a small number; set `optref` in `recomp/patches-v143.txt` guards main+0x1bd0138 for both | the crash dump's faulting host instruction, the register it loads through and the field that register came from |
## Device lost, hangs, black window
+3
View File
@@ -1133,3 +1133,6 @@ site grass main 1a30a98 52a83f48 @page:x8 b9409108 # mov w8, #31.25 -> ldr
# x8 and x9 are dead at the branch target 0x1622c1c, which loads x8 again.
set optref TOTK_OPTREF_GUARD 1
site optref main 1622bec b4000188 937ffd09 8a290108 b4000188 # cbz x8 -> asr x9, x8, #63; bic x8, x8, x9; cbz x8
# The freed-holder case of patches-v143.txt (main+0x1bd01c8): a target below 2^32 is never a live guest object and
# takes the game's own branch for a null target.
site optref main 1622bf4 b4000155 d360fea9 b4000149 # cbz x21 -> lsr x9, x21, #32; cbz x9
+8
View File
@@ -1128,3 +1128,11 @@ site grass main 2063460 52a83f48 @page:x8 b9409108 # mov w8, #31.25 -> ldr
# any read; on the fall-through path x8 is unchanged.
set optref TOTK_OPTREF_GUARD 1
site optref main 1bd01c0 b4000188 937ffd09 8a290108 b4000188 # cbz x8 -> asr x9, x8, #63; bic x8, x8, x9; cbz x8
# The reference at +0x6b0 is the holder of the PlayerVirtualKey request embedded at object +0x678 (vtable 0x7003678900,
# setHolder main+0x1bd1f78); the holder's first word is the target actor. A later report (LuizDavid48, 0.4.0) shows the
# holder itself freed: its first word read 0x80, an allocator header, and f_70000155ec faulted reading [0x80 + 0x10].
# The game already treats a target of 0 as absent (cbz x21 to 0x1bd01f0). Every guest object lies at or above 4 GiB:
# runtime/memory.c mem_init places the stack, heap, ASLR and alias regions from LOW_SEARCH_FROM (2^32) up and the
# modules and kernel region near 0x7000000000. So a target below 2^32 is never a live actor and takes the same branch:
# x9 = x21 >> 32, cbz x9. x9 is already overwritten by the site above on this path.
site optref main 1bd01c8 b4000155 d360fea9 b4000149 # cbz x21 -> lsr x9, x21, #32; cbz x9