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 from upstream-pr/2374 into main
Tauwni commented 2026-11-26 16:26:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tauwni on 2026-11-26T16:26:35Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5513651111 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2374). Originally posted by [Tauwni](https://github.com/Tauwni) on 2026-11-26T16:26:35Z. --- 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](https://claude.com/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](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7239890652)) | | `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](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7238921436)) | | `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](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7239812627)) | | `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.
aslan2142 commented 2026-12-01 12:33:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:33:12Z.


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.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311301257 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2374#issuecomment-7311301257). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:33:12Z. --- 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 commented 2026-12-01 12:56:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T12:56:06Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311861178 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2374#issuecomment-7311861178). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T12:56:06Z. --- 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 commented 2026-12-01 13:31:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T13:31:13Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7312753628 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2374#issuecomment-7312753628). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T13:31:13Z. --- 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 commented 2026-12-01 16:19:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tauwni on 2026-12-01T16:19:34Z.


@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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317415740 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2374#issuecomment-7317415740). Originally posted by [Tauwni](https://github.com/Tauwni) on 2026-12-01T16:19:34Z. --- @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 commented 2026-12-01 16:44:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:44:21Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318134994 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2374#issuecomment-7318134994). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:44:21Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2374
No description provided.