From e3ed92941b1aa7d567b279e3256bb931f2143a3c Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Sat, 24 Oct 2026 14:50:43 +0200 Subject: [PATCH] Don't check collected streams for kernel exceptions Memory freed together with the stream that last used it still names that stream as its owner, so reusing the memory waits for the collected stream. #739 made the waits treat a destroyed command list as done, but take_error! still synchronized the list directly to check for kernel exceptions, which segfaults in the driver on the destroyed handle. #739 was tested on a base without #731, which introduced that call. A collected stream has nothing left to report, and its report slot was released along with it, possibly to another stream, so return early. --- src/context.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/context.jl b/src/context.jl index 7bbbb30a..245e3546 100644 --- a/src/context.jl +++ b/src/context.jl @@ -486,6 +486,9 @@ function take_error!(s::oneStream) retire!(s) s.idle = true s.error === nothing || return s.error + # A collected stream can still be waited for (see `oneL0.destroyed`). It has nothing + # left to report, and its report slot was released with it, possibly to another stream. + oneL0.destroyed(s.immediate) && return nothing # Kernels may still write the report while the stream is busy. That is only the case # after waiting for it if another task submitted work in the meantime, in which case the # next synchronization reports the exception.