Skip to content

Commit 5618bb1

Browse files
Fix RNG crash on Windows (#2871)
This PR adds a Windows workaround for a crash on Battlemage during test runs. In oneMKL 2026.0 `mkl_rng::mt19937` destructor may crash with `STATUS_STACK_BUFFER_OVERRUN` during `DLL_PROCESS_DETACH` when using the Level Zero backend and static storage inside a DLL. The workaround heap-allocates `backend_sycl` singleton on Windows to avoid running its destructor at shutdown. Although `~backend_sycl()` is empty, it triggers destruction of its members (including `mkl_rng::mt19937`) which causes the crash. Since `backend_sycl` is a process-lifetime singleton, skipping its destruction is safe because OS reclaims all resources at process exit.
1 parent d67d3e3 commit 5618bb1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

dpnp/backend/src/queue_sycl.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,17 @@ class backend_sycl
6767

6868
static backend_sycl &get()
6969
{
70+
#if defined(_WIN32) && INTEL_MKL_VERSION == 20260000
71+
// TODO: remove once MKLD-19835 is resolved
72+
// mt19937 (oneMKL 2026.0) destructor crashes during DLL_PROCESS_DETACH
73+
// on Windows (Battlemage/Level Zero). Use a heap-allocated
74+
// process-lifetime singleton to skip destructor; OS reclaims memory.
75+
static backend_sycl *backend = new backend_sycl{};
76+
return *backend;
77+
#else
7078
static backend_sycl backend{};
7179
return backend;
80+
#endif
7281
}
7382

7483
static sycl::queue &get_queue()

0 commit comments

Comments
 (0)