From 1eb16bc9096a3b5098f6d7b4b40cdc16099495ba Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 21 Jul 2026 14:52:02 +0200 Subject: [PATCH] Pass CYTHON_USE_SYS_MONITORING=0 in coverage build. Force Cython's legacy (settrace-based) line tracing instead of the sys.monitoring path enabled by default on Python 3.13+. The sys.monitoring trace hooks emitted into the compiled extension fire exception/unwind events without preserving the in-flight exception, corrupting the interpreter error state when an exception propagates out of an instrumented .pyx frame (e.g. usm_ndarray.__dlpack__), turning it into a SystemError and hanging the coverage run. See https://github.com/cython/cython/issues/6658. --- dpnp/CMakeLists.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dpnp/CMakeLists.txt b/dpnp/CMakeLists.txt index d7acf368bcd0..f61e5b28c469 100644 --- a/dpnp/CMakeLists.txt +++ b/dpnp/CMakeLists.txt @@ -42,7 +42,12 @@ function(build_dpnp_cython_ext _trgt _src _dest) endif() if(DPNP_GENERATE_COVERAGE) - target_compile_definitions(${_trgt} PRIVATE CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1) + # Pass CYTHON_USE_SYS_MONITORING=0 to force Cython's legacy (settrace-based) + # line tracing instead of the sys.monitoring path + target_compile_definitions( + ${_trgt} + PRIVATE CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1 CYTHON_USE_SYS_MONITORING=0 + ) target_compile_options(${_trgt} PRIVATE "-fno-sycl-use-footer") endif() @@ -110,7 +115,13 @@ function(build_dpnp_tensor_ext _trgt _src _dest) endif() target_link_libraries(${_trgt} PRIVATE Python::NumPy) if(DPNP_GENERATE_COVERAGE) - target_compile_definitions(${_trgt} PRIVATE CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1) + # Pass CYTHON_USE_SYS_MONITORING=0 to force Cython's legacy (settrace-based) + # line tracing instead of the sys.monitoring path + # See https://github.com/cython/cython/issues/6658. + target_compile_definitions( + ${_trgt} + PRIVATE CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1 CYTHON_USE_SYS_MONITORING=0 + ) if(BUILD_DPNP_TENSOR_SYCL) target_compile_options(${_trgt} PRIVATE -fno-sycl-use-footer) endif()