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] 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