Commit graph

228 commits

Author SHA1 Message Date
andrewnakas
ace55528f3 Fix cross-thread use-after-free on WorldPresentation instance teardown
The intermittent map-load crash is heap corruption, not a null pointer.
It surfaces as a store through NULL in sub_8298CEF8 (intrusive list
unlink) reached from sub_82990768 +0x1D8, the guest small-block pool
allocator. Decoded with --protect_zero=true:

  sub_82990768  reads the chunk's free-block list head [chunk+8] and
                gets 0xFFFFFFFF, treats it as a free block, and rounds
                it down to a chunk header:
                ((0xFFFFFFFF+0x7FFF) & 0xFFFF8000) - 0x8000 = 0xFFFF8000
  sub_8298CEF8  node->next/prev at that address read as 0, so
                "next->prev = prev" stores through NULL

So the null store is three steps downstream. The defect is that
0xFFFFFFFF was in the free list at all.

Root cause, caught in the act by a store watch over the pool arena:

  WRITE INTO A FREE BLOCK: guest 0x40D22A6C, 2 bytes, thread "Job Manager"
    = +12 of free block 0x40D22A60 (size 64)
  writer:    sub_82816A40 <- sub_82817138 <- sub_82812A20
             <- sub_8290AFA0 <- sub_8290B750 <- sub_82A412B8
  freed by:  sub_82792040 <- sub_82791FD8 <- sub_82791500 (render_thread)

sub_82791CF8 (under Sk8::WorldPresentation::AddRenderInstance) allocates
two u16 arrays at self+496/+500 and publishes INTERIOR pointers into
them - &A[idx], &B[idx] - into other objects' +64/+68. A job work item
captures one at its +12 and walks it writing 4x u16 records. When
sub_82792040 frees those arrays on render_thread, the job keeps writing
into freed memory. If the block is on the pool's free list, the write
lands on its link word, which is how 0xFFFFFFFF gets there.

The fix, skate3_instance_free_defer_ms (default 0 = off), holds the
arrays freed by that teardown for N ms so a late job write lands on
memory the allocator has not reused. It is bounded by a 512 KB cap, so
a long job latency cannot starve the pool. This is a mitigation: the
root fix is draining or cancelling the outstanding jobs before teardown,
which needs a job-manager drain primitive I could not identify.

Also adds the diagnostics that found it, all default-off: a pool
integrity checker (per-alloc sweep of all 20 size-class bins, poison and
verify of freed blocks, and a check of the link word carried out of a
popped block), and the store watch's host side. The watch needs a
REX_STORE_* hook in the generated header, which is regenerated by
codegen and so is not included here.

Validation is honest but incomplete: 28 runs / 865 map-load events with
the fix on produced no corruption and no crash, but the corruption
occurred only ~2-3 times in ~3900 map-load events without it, so a clean
arm this size has close to even odds by chance. Longer soaks needed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-12 10:59:09 -06:00
mchughalex
f6e0ae87fd render: declare copy-source usage on the readback source textures 2026-07-24 21:49:05 +01:00
mchughalex
d1a3e3d255 installer: read the ISO install directory before the wizard moves the paths (SDK bump) 2026-07-24 20:47:39 +01:00
mchughalex
ceefe4dc37 docs: drop the antivirus section from the readme 2026-07-24 20:20:59 +01:00
mchughalex
15db3f9adb sdk: bump for the startup build-title log line 2026-07-24 19:54:03 +01:00
mchughalex
27667a79a5 docs: explain antivirus false positives in the readme 2026-07-24 19:40:48 +01:00
mchughalex
671e74ba59 build: embed version resources in the windows binaries (SDK bump) 2026-07-24 19:40:48 +01:00
mchughalex
12e71d3172 sdk: bump for the opt-in inexact vulkan render target transfer cvar 2026-07-24 19:39:41 +01:00
mchughalex
b6c6196c3e build: raise the dev version floor to 2.0.0 2026-07-24 19:13:37 +01:00
mchughalex
ebe14fcd1f render: recover streaming-revoked guest read faults on linux and macos 2026-07-24 19:03:31 +01:00
mchughalex
a37e74fb4d render: derive the auto frame cap from a refresh-scaled margin (SDK bump) 2026-07-24 13:38:02 +01:00
mchughalex
49690b290b sdk: bump for present-cadence logging and the native_rhi cstddef fix 2026-07-24 13:38:02 +01:00
mchughalex
a16314df0c capture: place sort-list batched piece clones with their instance matrix 2026-07-24 13:38:02 +01:00
mchughalex
14acde031b render: key rigid pose rings by instance identity and make their mispair gates rotation-aware 2026-07-24 13:38:02 +01:00
mchughalex
020af8ae90 capture: serve rigid instance worlds from the guest mesh context owner matrix 2026-07-24 13:38:02 +01:00
mchughalex
89360e53fc capture: pair deferred rigid clone worlds by identity instead of submission order 2026-07-24 13:38:02 +01:00
mchughalex
186c7de6f4 render: stand the static sun shadows down in venues with no sane world lighting capture 2026-07-24 13:38:02 +01:00
mchughalex
c9e501e298 render: pin the guest auto-exposure at its zone max while luminance readbacks are unavailable 2026-07-24 13:38:01 +01:00
mchughalex
5e52ef82e4 render: never adopt a material's own surface map as streamed ad art 2026-07-24 13:38:01 +01:00
mchughalex
a6efbc9553 readme: point the showcase link at the new video 2026-07-24 13:38:01 +01:00
mchughalex
587f5dc17f src: include cstddef in headers that use size_t 2026-07-24 13:38:01 +01:00
mchughalex
b046a436c5 video: use the 2x first-run render scale on macOS too 2026-07-24 13:38:01 +01:00
mchughalex
414015f525 macos: name the app bundle and window title skate3recomp 2026-07-24 13:38:01 +01:00
mchughalex
b2e4fc48a7 readme: link the native rendering showcase video 2026-07-24 13:38:01 +01:00
mchughalex
7329af15a8 render: default the frame cap to Auto (display refresh - 4) 2026-07-24 13:38:01 +01:00
mchughalex
7b0d690cf3 render: skip rebuilding occlusion-culled statics on most frames 2026-07-24 13:38:01 +01:00
mchughalex
8f8642aec2 render: time the submit-record loop and pre-size per-frame bookkeeping 2026-07-24 13:38:01 +01:00
mchughalex
2aef1222a0 render: skip guest draw-list dispatch for occlusion-culled statics 2026-07-24 13:38:01 +01:00
mchughalex
73c19c8cd3 render: occlusion-cull statics hidden behind rendered geometry 2026-07-24 13:38:01 +01:00
mchughalex
13447a041f render: profile the per-item CPU pipeline with occlusion-grid visibility attribution 2026-07-24 13:38:01 +01:00
mchughalex
70a7c55183 app: unload stream-probe cells before map transitions tear them down 2026-07-24 13:38:01 +01:00
mchughalex
87b27dc2a9 app: keep the stream-probe fan out of map loads 2026-07-24 13:38:01 +01:00
mchughalex
c0ba909c86 render: accumulate the static world-shadow map incrementally (SDK bump) 2026-07-24 13:38:01 +01:00
mchughalex
ceb98c34ec render: march sun shafts at quarter res with reach-proportional steps 2026-07-24 13:38:01 +01:00
mchughalex
4d616e4d45 render: mark the native scene passes for GPU-time attribution (SDK bump) 2026-07-24 13:38:01 +01:00
mchughalex
5fa92705a5 third_party: bump rexglue-sdk 2026-07-24 13:38:01 +01:00
mchughalex
e1ec3ac6b0 third_party: bump rexglue-sdk 2026-07-24 13:38:00 +01:00
mchughalex
dbb049bed4 third_party: bump rexglue-sdk 2026-07-24 13:38:00 +01:00
mchughalex
5a18cd8960 docs: README overhaul for the v2.0.0 native renderer release 2026-07-24 13:38:00 +01:00
mchughalex
b32b4332a8 third_party: bump rexglue-sdk 2026-07-21 11:40:02 +01:00
mchughalex
2b43fb2474 macos: self-contained application bundle with user files beside it (SDK bump) 2026-07-21 11:40:02 +01:00
mchughalex
25c68a89d7 ui: guard the settings-menu gamepad poll against runtime teardown 2026-07-21 10:50:13 +01:00
mchughalex
9fb6e5505f render: widen the content-store count caps now that byte budgets bound VRAM 2026-07-21 10:34:23 +01:00
mchughalex
6a52dcad6e system: macOS crash-free exit and Finder app launcher docs (SDK bump) 2026-07-21 10:33:27 +01:00
mchughalex
0224fdf74e render: budget the content stores by GPU bytes and LRU-evict the cube cache 2026-07-21 10:21:37 +01:00
mchughalex
1185533295 input: SDL controller backend option, res-scale seam and MnK stuck-bind fixes (SDK bump) 2026-07-21 10:11:01 +01:00
mchughalex
7fa9585285 render: compile the showcase gates out of the standard shader variants 2026-07-21 09:50:17 +01:00
mchughalex
137d97c190 render: keep showcase staging fully inert while no showcase frame is live 2026-07-21 09:31:00 +01:00
mchughalex
aa81e4e6c2 third_party: bump rexglue-sdk 2026-07-21 09:15:05 +01:00
mchughalex
3ed0d764fb third_party: bump rexglue-sdk 2026-07-21 09:04:21 +01:00