Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP: Move extra_mrs to not be shared via self
As of now at least, parallel tests share the `self` instance so
using it is always  a bit shady (but OK if it not mutated and
identical across threads).
`extra_mrs` is not, so let's pull it out.

I want to also see if there is any chance whether concurrent `close()`
might have caused bad things as I can't repro any of these crashes
locally.
  • Loading branch information
seberg committed Sep 9, 2026
commit 2ddbb5e7d99c9761d119b233136ec01130d2645c
20 changes: 10 additions & 10 deletions cuda_core/tests/memory_ipc/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_main(self, ipc_device, ipc_memory_resource):
# from PARENT_ACTION.
self.device = ipc_device
self.mr = ipc_memory_resource
self._extra_mrs = []
extra_mrs = []

try:
# Start a child process to generate error info.
Expand All @@ -134,7 +134,7 @@ def test_main(self, ipc_device, ipc_memory_resource):
process.start()

# Interact.
self.PARENT_ACTION(pipe[0])
self.PARENT_ACTION(pipe[0], extra_mrs)

# Check the error.
exc_type, exc_msg = pipe[1].get(timeout=CHILD_TIMEOUT_SEC)
Expand All @@ -146,7 +146,7 @@ def test_main(self, ipc_device, ipc_memory_resource):
assert not survivors, "child did not exit within timeout"
assert process.exitcode == 0
finally:
for mr in self._extra_mrs:
for mr in extra_mrs:
mr.close()

def child_main(self, pipe, device, mr):
Expand All @@ -166,7 +166,7 @@ def child_main(self, pipe, device, mr):
class TestImportOversizedBufferDescriptorSize(ChildErrorHarness):
"""Reject peer-supplied sizes larger than the mapped allocation extent."""

def PARENT_ACTION(self, queue):
def PARENT_ACTION(self, queue, extra_mrs):
stream = self.device.default_stream
self.buffer = self.mr.allocate(NBYTES, stream=stream)
payload, _ = self.buffer.ipc_descriptor.__reduce__()[1]
Expand All @@ -187,7 +187,7 @@ def ASSERT(self, exc_type, exc_msg):
class TestAllocFromImportedMr(ChildErrorHarness):
"""Error when attempting to allocate from an import memory resource."""

def PARENT_ACTION(self, queue):
def PARENT_ACTION(self, queue, extra_mrs):
queue.put(self.mr)

def CHILD_ACTION(self, queue):
Expand All @@ -202,10 +202,10 @@ def ASSERT(self, exc_type, exc_msg):
class TestImportWrongMR(ChildErrorHarness):
"""Error when importing a buffer from the wrong memory resource."""

def PARENT_ACTION(self, queue):
def PARENT_ACTION(self, queue, extra_mrs):
options = DeviceMemoryResourceOptions(max_size=POOL_SIZE, ipc_enabled=True)
mr2 = DeviceMemoryResource(self.device, options=options)
self._extra_mrs.append(mr2)
extra_mrs.append(mr2)
stream = self.device.default_stream
self.buffer = mr2.allocate(NBYTES, stream=stream)
stream.sync()
Expand All @@ -223,7 +223,7 @@ def ASSERT(self, exc_type, exc_msg):
class TestImportBuffer(ChildErrorHarness):
"""Error when using a buffer as a buffer descriptor."""

def PARENT_ACTION(self, queue):
def PARENT_ACTION(self, queue, extra_mrs):
# Note: if the buffer is not attached to something to prolong its life,
# CUDA_ERROR_INVALID_CONTEXT is raised from Buffer.__del__
stream = self.device.default_stream
Expand All @@ -246,10 +246,10 @@ class TestDanglingBuffer(ChildErrorHarness):
resource.
"""

def PARENT_ACTION(self, queue):
def PARENT_ACTION(self, queue, extra_mrs):
options = DeviceMemoryResourceOptions(max_size=POOL_SIZE, ipc_enabled=True)
mr2 = DeviceMemoryResource(self.device, options=options)
self._extra_mrs.append(mr2)
extra_mrs.append(mr2)
stream = self.device.default_stream
self.buffer = mr2.allocate(NBYTES, stream=stream)
buffer_s = pickle.dumps(self.buffer)
Expand Down
Loading