Skip to content

cuda.core: reject register() on a non-IPC memory resource - #2569

Open
fedonman wants to merge 1 commit into
NVIDIA:mainfrom
fedonman:fix-ipc-register-non-ipc-guard
Open

cuda.core: reject register() on a non-IPC memory resource#2569
fedonman wants to merge 1 commit into
NVIDIA:mainfrom
fedonman:fix-ipc-register-non-ipc-guard

Conversation

@fedonman

@fedonman fedonman commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Closes #2568.

DeviceMemoryResource.register() and PinnedMemoryResource.register() terminated the process with a segmentation fault when the memory resource did not have IPC enabled, including the default resource from Device().memory_resource. Both route through MP_register, which read self._ipc_data unconditionally although it is None unless IPC is enabled.

Changes

  • _ipc.pyx: check is_ipc_enabled in MP_register and raise RuntimeError("Memory resource is not IPC-enabled"), the wording the allocation_handle property already uses. The check runs before the registry insertion, so a rejected registration no longer leaves an entry behind.
  • tests/memory_ipc/test_errors.py: regression test covering the raise and the registry.
  • docs/source/release/1.2.0-notes.rst: release note. The defect is present in released 1.0.1, 1.1.0 and 1.1.1, so this is user-visible rather than confined to the current cycle.

Verification

Without the production change the new test does not merely fail, it takes the interpreter down (exit=139, SIGSEGV). With the change:

$ python -m pytest tests/memory_ipc/test_errors.py -k test_register_rejects_non_ipc -v
tests/memory_ipc/test_errors.py::test_register_rejects_non_ipc_memory_resource PASSED [100%]
======================= 1 passed, 14 deselected in 0.28s =======================

No regressions in the surrounding suites:

$ python -m pytest tests/test_memory.py tests/memory_ipc/ -q
192 passed, 133 skipped in 4.48s

MP_register read self._ipc_data._alloc_handle._uuid unconditionally.
_ipc_data is None whenever IPC is not enabled, and Cython compiles the
chained access without a none check, so the call terminated the process
with a segmentation fault instead of raising. No exception reached the
caller, so the crash could not be guarded with try.

Check is_ipc_enabled first and raise RuntimeError, matching the wording
the allocation_handle property already uses. The check runs before the
registry insertion, so a rejected registration no longer leaves an entry
behind.

Closes NVIDIA#2568

Signed-off-by: Vyron Vasileiadis <hi@fedonman.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: DeviceMemoryResource.register() segfaults when IPC is not enabled

1 participant