What changed
Check the age array's element count and data pointer before both reads in effect.age_pCtxI. An unavailable entry yields age zero through the original output loop. Valid indices still use the game's age calculation.
Add a Unicorn regression for the three recorded indices, valid lookups, the element-count boundary, and missing tables.
Why
D2R Mobile v2.3.0 crashed on macOS shortly after a summon-heavy Necromancer entered Claw Viper Temple Level 1 from Valley of Snakes. Three threads faulted at main+0x144f43c using 0x3eb2580f, 0x3c81dbf6, and 0x3fa28000 as indices. The values resemble float bit patterns. Their source and the exact gameplay trigger are still unconfirmed.
Related to #253, which covers the resource page lookup at main+0x1450294.
Checks run
-
python3 dm/i18n/scan_literals.pyreturnedI18N OK. -
python3 dm/ios/tools/dm_i18n.py --checkreturneddm_i18n OK 486 条. -
make -C dm/host/tests run -
make -C dm/gfx/tests run -
make -C dm/ios/tests test -
dm/verify/regress.sh --freshreturnedREGRESS OK fresh. The touch build also passed the structure and gate checks. -
cd dm/ios && ./run.sh build -
dm/ios/tools/smoke_mac.sh 1 -
dm/ios/tools/check_hud_gen.sh
The recorded indices reproduced the fault in the pre-fix image. The eight focused cases passed on all three rebuilt products.
On an Apple M4 Mac, the local build with this patch and #253 completed nine scripted transitions between the two areas with 20 summons and a hireling using an isolated save copy. The pre-fix build also completed that short route. The deterministic reproduction is the recorded-index test.
Visible changes
Valid lookups keep their existing rendering behavior. An unavailable entry uses age zero.
No game content
The diff contains only the rewriter change and the regression test.
Comments
- New explanatory comments are in Chinese and English.
Reviewed against the 3.3.94012 image (Android pack built from current main and from this branch, in docker):
0x144f418/0x144f43c). Wideningldr x12, [x13, #0x18]toldp x12, x17, [x13, #0x18]is safe: the loop at0x144f424–0x144f450never uses x17, and x13 is read before0x144f41coverwrites it. A missing entry stores 0 and skips the subtraction and the clamp.0x144f2dc/0x144f2f8). x9 is unused until0x144f300redefines it, soldp x17, x9, [x8, #0x18]is safe too. On a miss, x9 = x8 + x15 is exactly the output end the original computes at0x144f308. The fill loop at0x144f4f0uses only x8–x11 and s0, and leaves through the normal epilogue, so the stack stays balanced.+0x20is the element count, as the comment says:0x12d3440–0x12d34cccopies the array, keeps the count at+0x20and the capacity at+0x24.test_effect_age_lookup.pyfaults at0x144f43cwith the recorded indices on the current main image, and passes all 8 cases on the image from this branch. It needsdm/verifyonPYTHONPATHand the output folder'smain.fixups.tsvnext to the image.Looks correct to me. Since the float-shaped indices point at a stale or reused context after the area change, a one-time host log line when the guard trips (if a cheap svc hook is available there) might help find the real trigger later. Not needed for this fix.