From d922540757007884fd841a6c53556d3410a654fc Mon Sep 17 00:00:00 2001 From: dbakhval Date: Thu, 7 Jan 2021 16:07:37 -0800 Subject: [PATCH] [SYCL] Fix acquiring a mutex in _pi_context::finalize I observed crashes in ESIMD tests at the exit of _pi_context::finalize function. Unlocking not owned mutex is Undefined Behavior. Crashes occured only on Debug builds on Windows platforms when using LevelZero. I saw the following error: "unlock of unowned mutex". --- sycl/plugins/level_zero/pi_level_zero.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 77e8166b278a2..a0e7d01a0830c 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -459,7 +459,7 @@ pi_result _pi_context::finalize() { // There could be some memory that may have not been deallocated. // For example, zeEventPool could be still alive. std::lock_guard NumEventsLiveInEventPoolGuard( - NumEventsLiveInEventPoolMutex, std::adopt_lock); + NumEventsLiveInEventPoolMutex); if (ZeEventPool && NumEventsLiveInEventPool[ZeEventPool]) zeEventPoolDestroy(ZeEventPool);