Commit graph

34 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
671e74ba59 build: embed version resources in the windows binaries (SDK bump) 2026-07-24 19:40:48 +01:00
mchughalex
b6c6196c3e build: raise the dev version floor to 2.0.0 2026-07-24 19:13:37 +01:00
mchughalex
38343207ff render: split the scene and HDR shader sources into shared headers 2026-07-19 19:55:25 +01:00
mchughalex
146a158f90 render: extended draw distance and world streaming pre-load 2026-07-19 18:24:12 +01:00
mchughalex
13669fe589 render: peel the post-process passes into their own translation unit 2026-07-19 10:28:14 +01:00
mchughalex
e591f76f21 render: split the scene renderer into capture and GPU translation units 2026-07-19 10:19:22 +01:00
mchughalex
cb92f6aec5 render: promote the palette serve into its own module, retire the shadow observers 2026-07-19 09:32:57 +01:00
mchughalex
4ee3c458bf render: remove the shadow-mat observers and other dead diagnostics 2026-07-19 09:25:26 +01:00
mchughalex
80499b9f06 render: screen-space reflections (experimental, off by default) 2026-07-17 13:42:44 +01:00
mchughalex
3e09f33daf render: HDR scene pipeline + real bloom (SDK bump) 2026-07-17 12:07:38 +01:00
mchughalex
e19657a45d render: presentation-entity identity store + ROPA garment lifecycle 2026-07-17 11:15:27 +01:00
mchughalex
64fedeb7f0 render: GTAO screen-space ambient occlusion post pass (SDK bump) 2026-07-17 08:27:22 +01:00
mchughalex
22bd170bac scene: photo editor DoF fixed (typed-depth SRV read as cleared) + photo grab weave fixed 2026-07-15 04:21:19 +01:00
mchughalex
020051bf32 scene: finalize the 2D decode pipeline 2026-07-13 17:02:52 +01:00
mchughalex
b4d2e59b70 npc: LivingWorld entity store (per-instance opacity + identity + palettes) 2026-07-13 13:20:19 +01:00
mchughalex
2ac10ead44 render: texture decode, ropa cloth timing and scene fixes 2026-07-13 10:31:07 +01:00
mchughalex
cf274e7457 render: guest-structure probes + shadow-mode observers 2026-07-13 04:31:55 +01:00
mchughalex
406f47c79c render: move HLSL to source files, diagnostics TU, staged RenderScene 2026-07-11 10:58:36 +01:00
mchughalex
b99dbc400d exe icon from the player's own game files at runtime; close-clone prop jitter fix 2026-07-11 09:29:02 +01:00
mchughalex
acd77da02a F12 native-render debug menu: live feature toggles for bisecting regressions 2026-07-07 01:24:07 +01:00
mchughalex
70812600f7 in-world neon spline waypoints, F5 live renderer toggle, F6 screenshots, compass icon fixes 2026-07-05 01:38:10 +01:00
mchughalex
9f66afbe2a first native D3D12 scene renderer: live geometry pass replacing the emulated frame 2026-07-02 02:01:55 +01:00
mchughalex
2ad56d2d4b debug: frame snapshot harness and offline guest data-model reconstruction 2026-07-02 01:03:49 +01:00
mchughalex
dd6468bcff link Windows runtime statically 2026-06-30 23:33:32 +01:00
mchughalex
5bfd103702 default conservative Vulkan paths 2026-06-30 23:19:54 +01:00
mchughalex
1ff7ee7e87 support non-AVX2 x86_64 builds 2026-06-30 21:39:27 +01:00
mchughalex
c790817d56 add Skate 3 demo path 2026-06-14 12:02:09 +01:00
mchughalex
97df13cb01 add Skate 3 Title Update 3 support 2026-06-10 05:56:35 +01:00
mchughalex
1ed2841c5c add ultrawide and live FOV support 2026-06-10 05:56:34 +01:00
mchughalex
2c391fc45c prepare release 1.0.1 2026-06-06 15:16:27 +01:00
mchughalex
943d26e2d9 add macOS build and launch support 2026-06-06 15:15:18 +01:00
mchughalex
9beddc7b3e release version 1.0.0 2026-06-04 22:24:00 +01:00
mchughalex
62b65e74d8 create Skate 3 recompilation project 2026-05-18 23:03:10 +01:00