From c665cfd15450b0373006b3150c54c7a4457105d3 Mon Sep 17 00:00:00 2001 From: Yushuo Sun <135411736+yushuosun@users.noreply.github.com> Date: Mon, 29 Jun 2026 07:49:06 +1000 Subject: [PATCH] Fix run_nvrtc corrupting the interned 1-byte bytes singleton on empty NVRTC log When the NVRTC compile log is empty, nvrtcGetProgramLogSize returns size == 1 and `buf = b" " * size` returns the process-wide interned, immortal 1-byte bytes singleton b" ". nvrtcGetProgramLog is a zero-copy passthrough that writes a C-string NUL terminator through that buffer, mutating the shared singleton in place and corrupting b" " everywhere in the process. Allocate a writable, non-aliasing bytearray instead. --- nemo/core/utils/cuda_python_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nemo/core/utils/cuda_python_utils.py b/nemo/core/utils/cuda_python_utils.py index 1697d4815212..a86621028e8d 100644 --- a/nemo/core/utils/cuda_python_utils.py +++ b/nemo/core/utils/cuda_python_utils.py @@ -243,7 +243,7 @@ def run_nvrtc(kernel_string: str, kernel_name: bytes, program_name: bytes): assert_drv(err) err, size = nvrtc.nvrtcGetProgramLogSize(prog) assert_drv(err) - buf = b" " * size + buf = bytearray(size) (err,) = nvrtc.nvrtcGetProgramLog(prog, buf) assert_drv(err)