Skip to content

Commit e8903f1

Browse files
committed
Gate CudaSlice::leak() event waits behind is_managing_stream_synchronization
Same asymmetry as the Drop impl: leak() unconditionally waited on the read/write events before releasing ownership of the device pointer, which could hit the same invalid-event issue when tracking is disabled.
1 parent bb75e79 commit e8903f1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/driver/safe/core.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,11 +2470,13 @@ impl<T> CudaSlice<T> {
24702470
let ptr = s.cu_device_ptr;
24712471

24722472
// Ensure pending operations are complete before resources are released.
2473-
if let Some(read) = s.read.as_ref() {
2474-
s.stream.ctx.record_err(s.stream.wait(read));
2475-
}
2476-
if let Some(write) = s.write.as_ref() {
2477-
s.stream.ctx.record_err(s.stream.wait(write));
2473+
if s.stream.ctx.is_managing_stream_synchronization() {
2474+
if let Some(read) = s.read.as_ref() {
2475+
s.stream.ctx.record_err(s.stream.wait(read));
2476+
}
2477+
if let Some(write) = s.write.as_ref() {
2478+
s.stream.ctx.record_err(s.stream.wait(write));
2479+
}
24782480
}
24792481

24802482
// Manually drop fields that own resources.

0 commit comments

Comments
 (0)