Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion runtime/src/pipeline_workers.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,18 @@ 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. 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);
}
}

// Ends the workers once each has finished the job it is in. A run() in progress on another thread finishes its
Expand Down
Loading