Skip to content

Commit 3da6d66

Browse files
authored
Merge pull request #2314 from Jehan/wip/Jehan/fix-openblas-crash
Fix usage of TerminateThread() causing critical section corruption.
2 parents 08fa83a + 1f60715 commit 3da6d66

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

driver/others/blas_server_win32.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,15 @@ int BLASFUNC(blas_thread_shutdown)(void){
462462

463463
for(i = 0; i < blas_num_threads - 1; i++){
464464
// Could also just use WaitForMultipleObjects
465-
WaitForSingleObject(blas_threads[i], 5); //INFINITE);
465+
DWORD wait_thread_value = WaitForSingleObject(blas_threads[i], 5000);
466+
466467
#ifndef OS_WINDOWSSTORE
467-
// TerminateThread is only available with WINAPI_DESKTOP and WINAPI_SYSTEM not WINAPI_APP in UWP
468-
TerminateThread(blas_threads[i],0);
468+
// TerminateThread is only available with WINAPI_DESKTOP and WINAPI_SYSTEM not WINAPI_APP in UWP
469+
if (WAIT_OBJECT_0 != wait_thread_value) {
470+
TerminateThread(blas_threads[i],0);
471+
}
469472
#endif
473+
470474
CloseHandle(blas_threads[i]);
471475
}
472476

0 commit comments

Comments
 (0)