diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp index ba6a754458c2effd22d7b553d9e482b9c6a67673..1314a1563d0e9dcd466eb91b3e5b40c663f21608 100644 --- a/src/wrap_cl.hpp +++ b/src/wrap_cl.hpp @@ -1526,8 +1526,12 @@ namespace pyopencl std::thread notif_thread([cb_info]() { - std::unique_lock ulk(cb_info->m_mutex); - cb_info->m_condvar.wait(ulk); + { + std::unique_lock ulk(cb_info->m_mutex); + cb_info->m_condvar.wait(ulk); + + // ulk no longer held here, cb_info ready for deletion + } { py::gil_scoped_acquire acquire;