From dc52918a5174725b2b2b973a81030dc8574aa4af Mon Sep 17 00:00:00 2001 From: Tauwni <102470988+Tauwni@users.noreply.github.com> Date: Thu, 26 Nov 2026 17:26:18 +0100 Subject: [PATCH 1/2] pipeline_workers: keep the rethrown error alive across the throw, for 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 (#1086). Co-Authored-By: Claude Opus 5.5 --- runtime/src/pipeline_workers.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/src/pipeline_workers.h b/runtime/src/pipeline_workers.h index 664bfe0b85..4a104491e9 100644 --- a/runtime/src/pipeline_workers.h +++ b/runtime/src/pipeline_workers.h @@ -60,7 +60,14 @@ class PipelineWorkers { while (batch.next < batch.count) step(batch, lock); batch.done.wait(lock, [&] { return !batch.running; }); lock.unlock(); - if (batch.error) std::rethrow_exception(batch.error); + if (batch.error) { + // Wine 11.0's rethrow_exception throws the stored object itself, not a copy, so the exception_ptr in + // `batch` (a local of this frame) would free it while the throw unwinds, and the caller's handler would + // see no runtime_error. A thread_local reference keeps it alive until this thread's next error. + thread_local std::exception_ptr in_flight; + in_flight = std::move(batch.error); + std::rethrow_exception(in_flight); + } } // Ends the workers once each has finished the job it is in. A run() in progress on another thread finishes its From 377225afdaf19d9e27cb4d2be5c6aed646b587f5 Mon Sep 17 00:00:00 2001 From: Tauwni <102470988+Tauwni@users.noreply.github.com> Date: Tue, 1 Dec 2026 17:19:30 +0100 Subject: [PATCH 2/2] pipeline_workers: hold the in-flight exception through a thread_local 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 --- runtime/src/pipeline_workers.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/runtime/src/pipeline_workers.h b/runtime/src/pipeline_workers.h index 5d451896a2..48987eb9ca 100644 --- a/runtime/src/pipeline_workers.h +++ b/runtime/src/pipeline_workers.h @@ -70,10 +70,14 @@ class PipelineWorkers { if (batch.error) { // Wine 11.0's rethrow_exception throws the stored object itself, not a copy, so the exception_ptr in // `batch` (a local of this frame) would free it while the throw unwinds, and the caller's handler would - // see no runtime_error. A thread_local reference keeps it alive until this thread's next error. - thread_local std::exception_ptr in_flight; - in_flight = std::move(batch.error); - std::rethrow_exception(in_flight); + // see no runtime_error. A thread_local reference keeps it alive until this thread's next error. It is + // held through a plain pointer: a thread_local std::exception_ptr has a destructor, which adds a TLS + // callback (__dyn_tls_dtor) to gta6rt (gta6rt_no_tls_callbacks, AGENTS.md). One exception_ptr per + // thread that ever saw an error is never freed. + thread_local std::exception_ptr* in_flight = nullptr; + if (!in_flight) in_flight = new std::exception_ptr; + *in_flight = std::move(batch.error); + std::rethrow_exception(*in_flight); } }