Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

multiprocessing child segfault when passing lock as an argument #119413

Copy link
Copy link
@DylanZA

Description

@DylanZA
Issue body actions

Crash report

What happened?

It seems that the below code will serialize the pointer to the lock handle over to the child process, and then rebuild the raw pointer in https://github.com/python/cpython/blob/main/Modules/_multiprocessing/clinic/semaphore.c.h#L331

this then segfaults the child process - which seems to cause new children to spin up.

import multiprocessing
import os

def _init(l):
    print(os.getpid())
    print(l)

def main():
    ctx = multiprocessing.get_context(method="spawn")
    lock = multiprocessing.Lock()
    with ctx.Pool(1, initializer=_init, initargs=(lock,)) as pool:
        ret = pool.map(print, [1])

if __name__ == "__main__":
    main()

CPython versions tested on:

3.10, 3.11

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.