From f320d6a3f832341c4b16980335fef9fdf6223fb6 Mon Sep 17 00:00:00 2001 From: Kunal Nandanwar Date: Mon, 19 Jan 2026 14:45:49 -0800 Subject: [PATCH] Fix: Make StreamStack thread-local to prevent cross-thread interference Fixes #274 The StreamStack singleton was being shared globally across all threads, causing thread interference where one thread could see another thread'\''s active stream. This resulted in crashes when using cvcuda.Stream in multi-threaded applications. Solution: Changed the static singleton to thread_local static, ensuring each thread has its own StreamStack instance. Signed-off-by: Kunal Nandanwar --- python/mod_cvcuda/nvcv/StreamStack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/mod_cvcuda/nvcv/StreamStack.cpp b/python/mod_cvcuda/nvcv/StreamStack.cpp index 3bb9ee0b..b5038819 100644 --- a/python/mod_cvcuda/nvcv/StreamStack.cpp +++ b/python/mod_cvcuda/nvcv/StreamStack.cpp @@ -48,7 +48,7 @@ std::shared_ptr StreamStack::top() StreamStack &StreamStack::Instance() { - static StreamStack stack; + thread_local static StreamStack stack; return stack; }