Skip to content

ShareableList leaves its shared memory block behind when packing fails #161098

Closed

Description

@gpshead

Bug report

Bug description:

ShareableList(sequence) creates its shared memory block before packing the values into it. If packing then fails for a value of a supported type, such as an int outside the signed 64-bit range, the exception propagates and the new block stays behind, with no object left through which the caller could unlink it.

from multiprocessing import shared_memory

try:
    shared_memory.ShareableList([2**63], name='psm_demo')
except Exception as e:
    print(type(e).__name__, e)

shm = shared_memory.SharedMemory('psm_demo')  # succeeds; expected FileNotFoundError
print(shm.size)
shm.close()
shm.unlink()

Without name=, each failed call leaves one randomly named psm_* block in /dev/shm until the resource tracker exits.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. self-assigned this
    on Nov 1, 2026
  2. added a commit that references this issue on Nov 1, 2026
  3. added 2 commits that reference this issue on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions