Skip to content

pipeline_workers: keep the rethrown error alive for Wine 11.0's rethrow_exception; pipeline_workers passes under Wine - #2374

Closed
Tauwni wants to merge 5 commits into
ProjectLeonida:mainfrom
Tauwni:fix/pipeline-workers-rethrow-wine
Closed

Tauwni wants to merge 5 commits into
ProjectLeonida:mainfrom
Tauwni:fix/pipeline-workers-rethrow-wine

Conversation

@Tauwni

@Tauwni Tauwni commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Under Wine 11.0, pipeline_workers fails every round of its exceptions() case ("run() rethrew no exception, or not the lowest job's"). On native Windows and macOS it passes.

PipelineWorkers::run() (runtime/src/pipeline_workers.h) keeps the lowest job's error in the exception_ptr of a Batch on its own stack and ends with std::rethrow_exception(batch.error). Wine 11.0's rethrow_exception throws the stored object itself, not a copy. So the unwinding out of run() destroys batch, frees that object while it is still in flight, and the caller's catch (const std::runtime_error&) never sees it. #1086 found the same Wine behaviour in gta6rt's DllMain failure path and keeps a copy there.

Here the error type is whatever a job throws, so a copy of a known type doesn't fit. Instead, a thread_local std::exception_ptr takes the error just before the rethrow and keeps the object alive until that thread's next error. Nothing else changes: the lowest-index rule, the stop and the inline path for one job stay as they are.

Tested on an Apple M3 (macOS 26.5.1) at main fbf100b1b:

pipeline_workers the 18 tests matching pipeline
Wine 11.0 (WineHQ macOS build, x86-64 under Rosetta), clang-cl/lld-link 23.1.6 cross build, xwin SDK 10.0.26100 FAIL on main; PASS with this, 3 runs out of 3 16 pass; vk_pipeline_check_cli (a timeout) and pipeline_cache_seed fail with and without this change
native macOS, Apple clang 17 PASS (as on main) 10/10 pass, no new warnings

d3d12_pipeline_workers, d3d12_pipeline_workers_eager and replay_pipeline_compiles*, which run through PipelineWorkers, pass under Wine with this change.

AI-assisted (Claude Code). No game data.

🤖 Generated with Claude Code

Red checks: from main, not this change

The failing jobs (check, macos-python, stdlib-tests-linux, linux-gpu-tools, macos, windows) fail the same way on main d48a957bb (MEASURED on macOS for the Python tests, 1 run, with the same assertion text; GPU tests READ from this PR's CI logs). The open pull requests that fix them:

Failing on main Fixed by
test_docs_cli_flags #2536
test_make_game_preflight, test_progress_dashboard (repository URL) #2550
test_docs_repo_paths #2552 (all 14 paths; it conflicts with main, a merge is on Tauwni:fix/2552-merge-main, correction)
test_tool_stdout_encoding #2531, plus two scripts on Tauwni:fix/stdout-replace-two-new-scripts (no PR, open PR limit)
test_windows_boot_journal_seed #2514
test_docs_python_deps passes with the fixes above merged
test_build_runtime_fallback #2573 (passes with it, macOS, 1 run)
vk_bindless_dimensions (macOS) #2441
test_docs_env_vars DOC-CLWB-SETTING (fix)
test_make_game_pipelines, test_sampler_source_census, test_spirv_metal_set0_cli_errors, test_spirv_metal_set0_extra, tests/semantic/test_valu_cvt_f16_int16_mods.py, ps_exp_f32_denorm_rt (macOS) branches on Tauwni/leonida, no PR (finding)
cs_imgatomic_ext (macOS, linux-gpu-tools) #1518, closed without a comment
vk_xdxr_postbuild_readback (Windows) already passes on main: merge main

Not checked by a second agent or human yet.

… Wine 11.0's rethrow_exception

Wine 11.0's rethrow_exception throws the stored object itself, not a copy.
run() rethrew batch.error, the exception_ptr of a local Batch, which the
unwinding then freed, so the caller caught no runtime_error. A thread_local
exception_ptr now holds the object until the thread's next error. Same Wine
bug as gta6rt's DllMain failure (ProjectLeonida#1086).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142
aslan2142 marked this pull request as ready for review December 1, 2026 12:33
@aslan2142

Copy link
Copy Markdown
Collaborator

Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

@merzleckeier

Copy link
Copy Markdown
Contributor

Independent Windows binary A/B on two Wine builds for d4cb0b98 merged onto c95183fd8. I built the same pipeline_workers_test on main and with this PR. Under CachyOS Wine 10.0-20260425, the control failed all 50 repetitions of “run() rethrew no exception, or not the lowest job’s” and exited 1. The PR passed the entire suite and exited 0. Under system Wine 11.22 both binaries passed. This independently reproduces the lost exception on an older Wine build and verifies that the change restores the existing lowest-job exception contract there. Synthetic worker tasks only.

AI-assisted with OpenAI Codex.

@merzleckeier

Copy link
Copy Markdown
Contributor

Follow-up on the production TLS gate for the Wine fix. The earlier red/green worker test remains valid. I also built the production Win64 gta6rt.exe with Vulkan enabled, clang-cl 23.1.5 and /MD, on e04721c7 and on that same base plus d4cb0b98. The existing CTest gta6rt_no_tls_callbacks passes on main (no PE TLS callbacks) and fails with the PR. The production linker map names the added callback __dyn_tls_dtor. The Vulkan device object also contains the PipelineWorkers::run in_flight destructor and its __tlregdtor reference. This hits the guard documented under Runtime traps in AGENTS.md. The exception owner needs a lifetime that covers handling without introducing a C++ TLS destructor into gta6rt. This was a binary check with no title launch.

AI-assisted with OpenAI Codex.

Tauwni and others added 2 commits December 1, 2026 17:19
… pointer

A thread_local std::exception_ptr has a destructor, which put a TLS callback
(__dyn_tls_dtor) into gta6rt and failed gta6rt_no_tls_callbacks (found by
merzleckeier). A trivially destructible pointer to a heap exception_ptr keeps
the exception alive the same way, without one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tauwni

Tauwni commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@merzleckeier Thanks, that is a real regression and I had missed it. The new head holds the in-flight exception through a trivially destructible thread_local std::exception_ptr* (allocated on first error, never freed: one exception_ptr per thread that ever saw an error) instead of a thread_local std::exception_ptr, so no TLS destructor is registered. It also merges current main.

MEASURED, Apple M3, macOS 27.0, Apple clang, Release:

  • pipeline_workers_test: exit 0, 3/3 runs.
  • nm on pipeline_workers_test.cpp.o: _tlv_atexit (clang's TLS-destructor registration) appears once with the previous head and 0 times with this one. ASSUMED: the same holds for __dyn_tls_dtor with clang-cl on Windows.

Not run here: gta6rt_no_tls_callbacks on a Windows build, and the CachyOS Wine 10.0 A/B. A rerun of both at this head would confirm it.

Not checked by a second agent or human yet. AI-assisted: yes.

@aslan2142

Copy link
Copy Markdown
Collaborator

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

@aslan2142 aslan2142 closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants