Skip to content

runtime: report the memory region for a traced access violation (RT-STARTUP-TRACE) - #1096

Closed
Moriz82 wants to merge 1 commit into
ProjectLeonida:mainfrom
Moriz82:split/rt-startup-trace
Closed

Moriz82 wants to merge 1 commit into
ProjectLeonida:mainfrom
Moriz82:split/rt-startup-trace

Conversation

@Moriz82

@Moriz82 Moriz82 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue as: RT-STARTUP-TRACE (claim).

Part of the split of #984 into small pull requests.

Depends on: none
Overlaps: #984 (integration source). #41 adds caller information for a null target. #638 handles breakpoint skipping. Neither records the faulting address's memory region.

What and why

The opt-in startup trace records the address and operation of an access violation. Those fields alone cannot distinguish an unallocated range from a committed read-only page or a mapped view. When VirtualQuery succeeds, the exception event now includes the region base, allocation base, size, state, protection and type. A failed query leaves the rest of the event available. The handler continues exception processing as before.

Startup tracing remains off by default. Enable it with gta6rt --trace FILE.

Tested

Cross-built with clang-cl 23 and the xwin SDK. Ran the synthetic exception fixture under Proton Experimental (Wine 11) on CachyOS Linux 7.3, Ryzen 5 5600X and 16 GB RAM.

cmake --build runtime/build/boot --target gta6rt startup_trace_test -j6
ctest --test-dir runtime/build/boot -j1 -R '^startup_trace$' --output-on-failure
python3 -I scripts/check_no_game_data.py runtime/shims/startup_trace.h runtime/test/startup_trace_test.cpp
git diff --check
  • Base 3aa975421 with the new assertion passed 26/27 checks. The trace lacked the faulting page's region.
  • Child passed 27/27 checks and 1/1 CTest. The synthetic access violation reported free memory. The test also checks the access kind, exception location and stack.
  • Native Windows and AMD/Intel GPU runs were not performed.

GPUs tested: none. The fixture exercises CPU memory and exception tracing.
AI-assisted: yes

Checklist

  • Based on current upstream main at the cut. Merge check passed against the subsequently fetched main.
  • One topic with a synthetic regression test.
  • Content guard and whitespace check passed.
  • No translator rule changed.

🤖 Generated with Claude Code

…TARTUP-TRACE)

An access violation in the startup trace gives the address and operation but
does not identify the allocation or its page protection.

When startup tracing is enabled, query the memory region at the fault
address. Include its state, protection, type and allocation bounds when the
query succeeds. The exception handler continues its usual search.

Cross-built gta6rt and startup_trace_test. With the new assertion, 1 of 27
checks failed on the base. All 27 passed with the change under Wine.


AI-assisted (Codex and Claude Code agents).

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Plaaasma

Copy link
Copy Markdown
Contributor

Native Windows check, AI-assisted (Claude Code). Windows 11, i9-13900K, 64 GB, RTX 4070 Ti 12 GB (NVIDIA 630.20), MSVC 2022 (VS 17 generator, Release), Vulkan.

Head 51868dfbe. Built startup_trace_test, then ctest -C Release -R "^startup_trace" --output-on-failure --timeout 300:

  • startup_trace: passed, 0.14 s (27 check(s), 0 failed)

1 passed, 0 failed.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audited and verified. Enriches access violation diagnostic logging in
untime/shims/startup_trace.h with VirtualQuery memory region details (�ase, �llocation_base, size, state, protect, ype). Verified in
untime/test/startup_trace_test.cpp. Clean-room compliant. Approved.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean-Room Audit — PR #1096 (RT-STARTUP-TRACE Access Violation Region Info)

Very helpful diagnostic improvement in runtime/shims/startup_trace.h: logging VirtualQuery region metadata (base, allocation_base, size, state, protect, type) on access violations makes unmapped/guard/free-memory stops immediately diagnosable. Cleanly verified in runtime/test/startup_trace_test.cpp; 0 game data.

Verdict: APPROVED

@Deedlyy

Deedlyy commented Nov 24, 2026

Copy link
Copy Markdown

Recommendation: [MERGE]

Reasoning: Adds the VirtualQuery memory region to the opt-in startup trace's access-violation event (+10 lines), part of the #984 split. Diagnostic only, behind an opt-in trace. Verified natively on Windows by Plaaasma (startup_trace passes). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 2/10

@whoalin1

Copy link
Copy Markdown
Contributor

GPU verification (AI-assisted, independent worker on the shared test box) — head 51868dfbe. Note: this PR is based on 3aa975421, not current origin/main (58be9cdf8).

Change is 8 lines in runtime/shims/startup_trace.h (VirtualQuery region info appended to the logged access-violation record) plus one new check in startup_trace_test.cpp.

Host tests (ctest -R 'startup_trace|run_startup', TEMP/TMP pointed at a user-writable dir — agent shells otherwise default to C:\Windows and these tests fail with 0xc0000409, environmental): 2/2 passed — startup_trace (26 checks incl. the new "region" assertion: base 0x0, state MEM_FREE for the null dereference) and run_startup_cmdline.

GPU suite py -3.14 -I scripts/run_gpu_tests.py --build runtime/build on the AMD Radeon iGPU (gfx1035, driver 24.10.24, Vulkan 1.3.280): VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon VK_LOADER_LAYERS_DISABLE=~implicit~ LEONIDA_VK_VALIDATION=1 LEONIDA_PC_TAIL_UBO=1, LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc → 230/252 passed, 20 skipped, 2 failed: ms_clip and ms_wave_info_s3, byte-identical to the origin/main baseline on this machine — known AMD LLPC issue (#802/#808). 261 shaders translated, 261 pass spirv-val. No validation errors.

Verdict: PASS — low-risk instrumentation; host coverage and a full validated GPU pass show no regressions.

clquwu pushed a commit to clquwu/leonida-ultimate that referenced this pull request Nov 25, 2026
…984 LAYOUT_UNDEFINED, Wave-21b CMake & leonida-ce 525c44e1 ReadFile fast-path

- ProjectLeonida/mandy#1100 (RT-PLACED-IMAGE-DEFER): unify Resource deferred memory binding onto leonida::DeferredImageBinding (deduping duplicate flags/mutex), add LEONIDA_PLACED_IMAGE_DEFER=0 rollback, defer placed depth/UAV/RT attachments + cpu_copy bind + race-free memory_flags(), preserve MemoryPriority, add check_placed_target_backing test & docs/d3d12_vulkan.md note.
- ProjectLeonida/mandy#1099 (RT-STREAM-TRANSFER-BARRIER): deduped against existing ultimate CopyBuffer/CopyResource transfer barriers; add LEONIDA_ORDER_BUFFER_COPIES=0 opt-out toggle, --expect-unordered test mode, and docs/d3d12_vulkan.md note.
- ProjectLeonida/mandy#1097 (SHADER-BUFFER-BOUNDS): use OobSelect::structured_with_offset for structured buffer SRVs in d3d12_vulkan_device.cpp, add cross-record GPU readbacks in d3d12_compute_test.cpp + cs_user_data.comp (and align Xbox slot-17 CBV expectations with wave18b vector-row encoding).
- ProjectLeonida/mandy#1096 (RT-STARTUP-TRACE): add VirtualQuery memory region metadata on access violations in startup_trace.h & startup_trace_test.cpp.
- ProjectLeonida/mandy#1023 & #1007: update docs/directstorage.md (measured factory IID & slot 8) and docs/d3d12_vulkan.md (device slot 62 5-arg arity & slot 76 FFX-only note).
- Wave-21b deferred CMake: add loader TIMEOUT 180 (Reforge#169) and tiny_game_ga / run_tiny_game_ga_tls (ubiq#947 Patch 2).
- ProjectLeonida/mandy#984 (self-contained Windows-native port): accept enhanced TextureBarrier into LAYOUT_UNDEFINED without violating VUID-VkImageMemoryBarrier2-newLayout-01198 (command_list.h, vulkan_replay.h, command_list_test, replay_texture_barrier_test, d3d12_close_parity_test).
- IAmNotSiob/leonida-ce 525c44e1 (GPL-3.0, deduped): wire optional xmem::commit_physical_range_fn hook into file_system.cpp ReadFile ERROR_NOACCESS retry path to commit large console buffers without per-page VEH faults while keeping zero-cost fast path and touch_pages fallback.
- DesignWithTommy/Neonbridge eaf7e7e0: audited and skipped (ultimate has no refresh read-back byte/time cap skipping Bink R8/R8G8 planes).
@Moriz82

Moriz82 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

Current main already reports the memory region for a traced access violation and includes the same startup-trace test. #984 brought in both. A rebase leaves a single source comment describing that behavior.

For the check alert on 51868df, Runtime, No Game Data, and CI ran zero jobs while waiting for maintainer approval. The label job was cancelled before a runner picked it up. A trial merge against 5129be10 adds just the comment. The trace fields and test are already in #984.

AI-assisted.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@Moriz82 Moriz82 closed this by deleting the head repository Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants