Mission terminal bitmap clear crash: bounded source audit
Date: 2026-10-27. Scope: maintained C, runtime support source, and retained
runtime/errors.json only. No binary inspection, REA sessions, browser actions,
builds, test processes, or production source changes were performed by this
worker. The parent investigator owns served-binary identity verification and
original-instruction comparison. Addresses below refer to maintained C comments;
they are not independent claims about freshly inspected original machine code.
Leading finding
The maintained 16-bit bitmap fill path has a concrete zero-count REP translation
bug that can abort at exactly one-past the backing allocation. This is a strong,
testable explanation for the page-aligned unmapped address 0x63880000 and the
intermittent terminal-opening behavior. Attribution of this particular captured
crash still requires the fault-time bitmap fields or a targeted reproduction.
In client/game/bbr.dll/lifted-0040.c, sub_250AF340 fills a bitmap rectangle.
Its 16-bit path writes pairs with rep stosd at 0x250AF4FF, then an optional
remaining pixel with rep stosw at 0x250AF503. After an even-width row, the
second repeat count is zero. Nevertheless, generated C evaluates
ADDR(edi) before calling MEMSET16(..., count=0). If the final row ends at an
unmapped page, guest_address aborts while translating that one-past address.
No pixel write is required for the failure.
client/runtime/guest_memory.h explicitly checks the page mapping in portable
non-Linux-64-bit builds, including WASM. MEMSET16 in
client/runtime/recomp_types.h correctly performs zero writes for count zero,
but that check happens after its pointer argument has already been translated.
The x86 zero-count REP contract requires that the operation access no memory.
The key maintained C sequence is:
0x250AF4FB: shift width right by one, retaining odd/even in carry.0x250AF4FF: writewidth / 2doublewords; EDI advances to row end for an even width.0x250AF501: recover the remaining-pixel count using carry, giving zero for even width.0x250AF503: unconditionally translate EDI for a zero-countMEMSET16.
Heap placement can make this intermittent: client/runtime/guest_heap.c
suballocates and reuses ranges in mapped arenas, so a one-past bitmap address may
sometimes remain mapped and sometimes coincide with an unmapped arena boundary.
This is an explanatory inference, not captured allocator-state evidence.
Calling path and initialization
The retained crash stack identifies sub_250AF340, called by
sub_2B085270, then sub_2B086BC0, during the generic command UI path. The
captured unmapped address is 0x63880000.
client/game/ddr.dll/lifted-0034.c, sub_2B085270, initializes the mission UI.
It sets intended dimensions to 480 by 480 at 0x2B085320 and 0x2B08532E,
constructs an image via IAT 0x2B0B5BD8 at 0x2B085366, stores the image at
UI offset 0x84, obtains the image's bitmap at offset 0x28, then calls IAT
0x2B0B564C at 0x2B085385 with (rect=NULL, color=0, flag=1). The retained
stack resolves that call to sub_250AF340.
This clear happens before the remaining mission window widgets are constructed. The source does not establish a reward-item ownership or armor equip error. Those preceding actions might change heap placement, but causation is unknown. The image constructor's actual bitmap dimensions/format were not established by this worker; the 480 by 480 intended UI dimensions do not prove the backing bitmap's dimensions.
client/game/ddr.dll/lifted-0035.c, sub_2B086BC0, allocates a new 0x140-byte
mission UI and invokes sub_2B085270 at 0x2B086C7E. The completed UI pointer
0x2B0EF0DC is assigned only after the constructor returns. The constructor
also publishes its in-progress object at 0x2B0EF0D4 before the failing clear,
which makes the latter useful for a postmortem probe.
Exact confirmation probe
Without resuming the aborted client, read:
ui = MEM32(0x2B0EF0D4)
image = MEM32(ui + 0x84)
bitmap = MEM32(image + 0x28)
pixels = MEM32(bitmap + 0x00)
height = MEM32(bitmap + 0x08)
width = MEM32(bitmap + 0x0C)
pitch = MEM32(bitmap + 0x20)
bpp = MEM32(bitmap + 0x24)
mode = MEM32(bitmap + 0x2C)
format = MEM32(bitmap + 0x30)
The leading diagnosis predicts bpp == 2, an even width, and the final row's
one-past endpoint equal to 0x63880000. For a tightly packed full-surface fill,
that endpoint is pixels + height * pitch. Confirm the page containing the
last valid pixel is mapped and the endpoint's page is not. A still-readable
fault frame can additionally establish that the active source operation is
0x250AF503 and its repeat count is zero. A 32-bit bitmap would falsify this
specific trailing-halfword explanation.
Minimal fix and readable rewrite candidate
The smallest correct repair is to guard the zero-count REP operation before
evaluating ADDR, preserving register, stack, and flag semantics. Changing
MEMSET16 alone cannot fix argument evaluation. Mapping an extra page or
clamping dimensions would hide the defect.
If a readable rewrite is preferred, replace only sub_250AF340 with a bitmap
fill that retains its public guest ABI, existing rectangle clipping helper
sub_250B02D0, existing color conversion sub_250D84E0, and 16-bit mode-2 flag
behavior. Compute each row from the byte pitch; write exactly the requested
number of 2-, 3-, or 4-byte pixels. Translate addresses only for actual writes.
Keep the wrapper's callee-saved registers and stack cleanup. An unrelated
mission constructor rewrite is not justified by the current evidence.
Other bounded source observations
sub_250AF340 receives a NULL rectangle for this call. It therefore derives
the full rectangle directly from bitmap width/height, without the clipping
helper used for explicit rectangles. It trusts valid surface fields.
sub_250AF260, in the same BBR source file, initializes a bitmap with width at
+0x0C, height at +0x08, bpp at +0x24, pitch at +0x20, and raw pixels at
+0x00. It computes pitch = width * bpp and allocates height * pitch with
32-bit arithmetic. Normal small UI sizes do not suggest integer overflow;
corrupt surface fields or allocation state remain unexcluded until probed.
The 24-bit fill branch also contains suspicious row-padding arithmetic:
0x250AF465 computes pitch * (pitch / bpp - rect_width), which is then added
after each row at 0x250AF492. Expected byte padding for an ordinary packed
24-bit layout is pitch - 3 * rect_width. This is a separate source-observed
problem for partial-width or padded 24-bit fills. It is not established as the
terminal crash cause and should not be used as proof of this crash.
Targeted verification
Use the public bitmap fill entry point rather than a private helper:
- Two-byte pixels, even width, allocation ending exactly at a mapped page boundary with the next page unmapped: full clear must complete, set the last pixel, and preserve guards. This should fail before the zero-count repair.
- Two-byte pixels, odd width: verify the final halfword is written correctly.
- Four-byte and three-byte formats: verify exact color bytes and row pitch.
- An explicit clipped rectangle, including a nonzero origin, preserves pixels outside the rectangle and row padding; an empty/outside rectangle writes none.
- Two-byte format mode 2 with the auxiliary flag both zero and one preserves the documented source behavior for bit 0x8000.
- Guest ABI checks cover callee-saved registers and return-stack position.
A Linux x86-64 native fixture alone may not catch the zero-count translation: its guest-address helper uses a reserved address range and does not consult the portable page table. Exercise the portable page-table implementation or WASM. Then repeat real mission terminal opening/closing around hand-in and armor equip/unequip in the WASM client, capturing complete errors and served build identity. The older TODO P0 incident is plausibly the same defect, but identical stack or reproduction evidence is still needed before equating them.
Remaining unknowns
- Fault-time bitmap fields and exact failing source operation.
- Served compressed WASM identity relative to the current symbols/source.
- Original-machine-code confirmation of the relevant repeat instruction and constructor call (owned by the parent REA investigation).
- Whether the earlier
local/mission-retirement/event-crash-*incident has the same stack or merely the same UI trigger.
No tests were run by this read-only worker. No repair is claimed.
Parent verification and repair
The maintained BBR image SHA256 is 79978fd5184b809c8df7f843dafbdcb899557037dc17372c2903a570b8eba7d3. Focused native disassembly confirms SHR ECX,1 at250af4fb, REP STOSD at250af4ff, ADC ECX,ECX at250af501 and REP STOSW at250af503. Exact native bytes are retained in bbr-clear-native.txt. REA's original DDR constructor independently confirms its initial480x480 render-window allocation and immediate Clear call before native terminal widgets are created (ddr-evidence.json).
The new public bitmap-clear fixture ends a480x48016-bit bitmap at unmapped page50080000. Unchanged C aborts at exactly that address in both the paged native build and WASM; the normal Linux64 mapping happens not to validate a zero-count pointer translation. A guard around the zero-count trailing STOSW passes all11 fixture cases in both native memory modes and WASM, including width1/2/3/480, padding, empty dimensions, alpha and preserved ABI. This proves the defect and correction without inventing fault-time fields for the earlier browser capture. bitmap-regression.json retains the exact results.