mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
fix: skip cleanup in DllMain when terminating process
Per https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain, it's not safe to cleanup resources in DllMain when fdwReason == DLL_PROCESS_DETACH and lpvReserved != NULL (the process is terminating), e.g. can result in a hang in some cases. Related-To: NEO-14121 Signed-off-by: Oskar Hubert Weber <oskar.hubert.weber@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
bf8de245d9
commit
0b5c9125ac
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -13,7 +13,11 @@ using namespace NEO;
|
||||
|
||||
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { // NOLINT(readability-identifier-naming)
|
||||
if (fdwReason == DLL_PROCESS_DETACH) {
|
||||
globalPlatformTeardown();
|
||||
/* If lpvReserved is non-NULL with DLL_PROCESS_DETACH, the process is terminating,
|
||||
* cleanup should be skipped according to the DllMain spec. */
|
||||
if (!lpvReserved) {
|
||||
globalPlatformTeardown();
|
||||
}
|
||||
}
|
||||
if (fdwReason == DLL_PROCESS_ATTACH) {
|
||||
globalPlatformSetup();
|
||||
|
||||
Reference in New Issue
Block a user