Skip to content

Commit 2cc9adb

Browse files
Andy-Jostclaude
andauthored
test(cuda.core): pickle a fresh harness instance for the IPC child process (#2868)
ChildErrorHarness.test_main passed the bound method self.child_main as the Process target, so a rerun pickled the instance together with state left by the failed attempt, such as a buffer whose memory resource the finally block had already closed. Every rerun then failed inside pickling and hid the original failure. Target a fresh instance instead so nothing from an earlier attempt is pickled. Issue #2775 Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 8b9bc03 commit 2cc9adb

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎cuda_core/tests/memory_ipc/test_errors.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ class ChildErrorHarness:
120120

121121
@pytest.mark.thread_unsafe(
122122
reason=(
123-
"pytest-run-parallel reuses the same instance and ipc fixtures across "
124-
"workers; Process(target=self.child_main) pickles that shared state (#2784)"
123+
"pytest-run-parallel shares the ipc fixtures across workers; "
124+
"Process(target=...) pickles that shared state (#2784)"
125125
)
126126
)
127127
@pytest.mark.flaky(reruns=2)
@@ -134,9 +134,12 @@ def test_main(self, ipc_device, ipc_memory_resource):
134134
self._extra_mrs = []
135135

136136
try:
137-
# Start a child process to generate error info.
137+
# Start a child process to generate error info. Target a fresh
138+
# instance: pickling ``self`` would also ship state left behind by
139+
# an earlier attempt, such as a buffer whose resource is closed.
138140
pipe = [multiprocessing.Queue() for _ in range(2)]
139-
process = multiprocessing.Process(target=self.child_main, args=(pipe, self.device, self.mr))
141+
child = type(self)()
142+
process = multiprocessing.Process(target=child.child_main, args=(pipe, self.device, self.mr))
140143
process.start()
141144

142145
# Interact.

0 commit comments

Comments
 (0)