Skip to content

Commit 3edbe8f

Browse files
committed
Merge #268: Use throwRecoverableException instead of raw throw for stored exceptions
23be44b Use throwRecoverableException instead of raw throw for stored exceptions (Alfonso Roman Zubeldia) Pull request description: Replace `throw kj::mv(*exception)` with `kj::throwRecoverableException(kj::mv(*exception))` in the async worker thread exception handler in `type-context.h`. A raw throw creates a `kj::Exception` with the calling binary's typeinfo. On macOS with `-fvisibility=hidden`, this typeinfo is not coalesced with `libkj.dylib`'s copy by the dynamic linker, so `getCaughtExceptionAsKj()`'s `catch (kj::Exception& e)` fails and falls through to `catch (...)`, producing `unknown non-KJ exception of type: kj::Exception` errors. `throwFatalException()` routes the throw through libkj, wrapping it in `ExceptionImpl` with consistent typeinfo. This matches the pattern KJ uses internally in `kj/async-inl.h` when re-throwing stored exceptions from promises. Context: bitcoin/bitcoin#34723, bitcoin/bitcoin#35014 ACKs for top commit: Sjors: ACK 23be44b ryanofsky: Code review ACK 23be44b. Thanks for the fix! Tree-SHA512: b23e43b188255e76c499376f30e09db0868ab0dcc7fa4bd0b0f1ed38ab719d1c0a5e4a6cf7e2eb598a55ebdd0c28dda50623bdbf003ff56c3b6483ba1db916ee
2 parents 75c2a27 + 23be44b commit 3edbe8f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

include/mp/type-context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
189189
}
190190
})) {
191191
MP_LOG(loop, Log::Error) << "IPC server request #" << req << " uncaught exception (" << kj::str(*exception).cStr() << ")";
192-
throw kj::mv(*exception);
192+
kj::throwRecoverableException(kj::mv(*exception));
193193
}
194194
return call_context;
195195
// End of scope: if KJ_DEFER was reached, it runs here

0 commit comments

Comments
 (0)