dotnet/runtime · warning
coreclr_shutdown_2 failed - Error: 0x%08x
Error message
coreclr_shutdown_2 failed - Error: 0x%08x
What it means
Printed at src/coreclr/hosts/corerun/corerun.cpp:689 when coreclr_shutdown_2 returns a failing HRESULT during runtime teardown. Shutdown failures are usually non-fatal for the program result (the process is exiting anyway), but indicate a leak, a lingering thread, or an unloading AppDomain error.
Solutions
- Ensure all managed background threads/tasks are stopped before Main returns.
- Treat the exit code as -1 only when shutdown actually failed; otherwise prefer the latched exit code.
- Upgrade the runtime to a version with shutdown-path fixes if the HRESULT points to a known bug.
- If reproducible, capture a dump at shutdown to inspect outstanding handles/threads.
Defensive patterns
Strategy: try-catch
Try / catch
// corerun_shutdown is internal; users cannot catch it. Instead, ensure clean state before exit: // stop all background tasks in Main, then return. The host's exit code reflects -1 only on real failure.
Prevention
- Stop all managed background threads/tasks before Main returns.
- Do not hold native references into the runtime past execution.
- Use a runtime version with known shutdown fixes.
- Capture a shutdown dump if the warning is reproducible.
When it happens
Trigger: Triggered inside corerun_shutdown when the resolved coreclr_shutdown_2 export returns FAILED(result). Typical causes: background managed threads still running, unhandled exceptions during finalization, or a bug in the runtime's unload path.
Common situations: Observed when the managed program started background tasks that were not stopped, when native host code holds references preventing clean unload, or with runtime builds that have known shutdown bugs.
Related errors
- BEGIN: coreclr_execute_assembly failed - Error: 0x%08x
- BEGIN: coreclr_initialize failed - Error: 0x%08x
- END: coreclr_execute_assembly failed - Error: 0x%08x
- END: coreclr_initialize failed - Error: 0x%08x
- Export ' ' not found.
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/da234fe56bac7620.
Report an issue: GitHub.
Appendix: source
Thrown at src/coreclr/hosts/corerun/corerun.cpp:689
}
#endif // TARGET_WASI
return final_exit_code;
#endif // TARGET_BROWSER
}
extern "C" int corerun_shutdown(int exit_code)
{
coreclr_shutdown_2_ptr coreclr_shutdown2_func = nullptr;
if (!try_get_export(coreclr_mod, "coreclr_shutdown_2", (void**)&coreclr_shutdown2_func))
{
return -1;
}
int latched_exit_code = 0;
int result = coreclr_shutdown2_func(CurrentClrInstance, CurrentAppDomainId, &latched_exit_code);
if (FAILED(result))
{
pal::fprintf(stderr, W("coreclr_shutdown_2 failed - Error: 0x%08x\n"), result);
exit_code = -1;
}
if (exit_code != -1)
exit_code = latched_exit_code;
::free((void*)s_core_libs_path);
::free((void*)s_core_root_path);
return exit_code;
}
// Display the command line options
static void display_usage()
{
pal::fprintf(
stderr,
W("USAGE: corerun [OPTIONS] assembly [ARGUMENTS]\n")
W("\n")View on GitHub (pinned to 60108ba66e)