#254

Guard particle effect age lookups after area transitions

Openrhotovwants to merge intofrom

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.py returned I18N OK.
  • python3 dm/ios/tools/dm_i18n.py --check returned dm_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 --fresh returned REGRESS 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.

Activity

2
yyan16010d ago

Reviewed against the 3.3.94012 image (Android pack built from current main and from this branch, in docker):

  • Per-element path (0x144f418 / 0x144f43c). Widening ldr x12, [x13, #0x18] to ldp x12, x17, [x13, #0x18] is safe: the loop at 0x144f424–0x144f450 never uses x17, and x13 is read before 0x144f41c overwrites it. A missing entry stores 0 and skips the subtraction and the clamp.
  • Constant path (0x144f2dc / 0x144f2f8). x9 is unused until 0x144f300 redefines it, so ldp x17, x9, [x8, #0x18] is safe too. On a miss, x9 = x8 + x15 is exactly the output end the original computes at 0x144f308. The fill loop at 0x144f4f0 uses only x8–x11 and s0, and leaves through the normal epilogue, so the stack stays balanced.
  • +0x20 is the element count, as the comment says: 0x12d3440–0x12d34cc copies the array, keeps the count at +0x20 and the capacity at +0x24.
  • test_effect_age_lookup.py faults at 0x144f43c with the recorded indices on the current main image, and passes all 8 cases on the image from this branch. It needs dm/verify on PYTHONPATH and the output folder's main.fixups.tsv next 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.