From 1d7350424229b0d34e7c1836f4507936a1a41cb8 Mon Sep 17 00:00:00 2001 From: RaulOrtizSanchez <122691427+rrrarrra9@users.noreply.github.com> Date: Mon, 23 Nov 2026 16:50:42 +0100 Subject: runtime: retain import report when initialization fails (#6835) Squash-merged after diff review of PR #6835 - RT-486: Retain the import binding report when initialization fails --- runtime/src/main.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'runtime/src/main.cpp') diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index b75baf15f..71a5b44e1 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -179,9 +180,15 @@ int wmain(int argc, wchar_t** argv) { r.error); } if (run) rt::process::set_command_line(image.filename().wstring(), game_args); + std::exception_ptr init_failure; if (init || run) { - loader.initialise(); // TLS callbacks, then DllMain(DLL_PROCESS_ATTACH) for DLLs - std::printf("%zu module(s) initialised\n", loader.modules().size()); + try { + loader.initialise(); // TLS callbacks, then DllMain(DLL_PROCESS_ATTACH) for DLLs + std::printf("%zu module(s) initialised\n", loader.modules().size()); + } catch (const std::exception&) { + // Keep the mapped modules available for the binding report on an attach failure. + init_failure = std::current_exception(); + } } int unimplemented = 0, unimplemented_hresult = 0; for (auto* m : loader.modules()) { @@ -205,6 +212,10 @@ int wmain(int argc, wchar_t** argv) { std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented); std::printf("unimplemented by return policy: hresult=%d other=%d\n", unimplemented_hresult, unimplemented - unimplemented_hresult); + if (init_failure) { + std::fflush(stdout); + std::rethrow_exception(init_failure); + } if (!run) { rt::startup_trace::event("exit", "\"code\":0"); return 0; -- cgit v1.2.3