Skip to content

holding GIL on non-sticky tasks leads to undefined behavior #809

Description

@kleinschmidt

Affects: PythonCall

Describe the bug

Because the Python GIL is specific to an OS thread, but Julia tasks can migrate across threads when they're paused/resumed, locking the GIL from Julia on a non-sticky thread leads to undefined behavior (segfaults, deadlocks, etc.).

I think probably the way to handle this is to mark the current task as sticky in GIL.@lock and friends. It's really hard to get this right in libraries that wrap provide python functionality because even if callers know they need to lock the GIL, they may not know about task stickiness.

Your system

We've seen this across a wide variety of environments, Julia 1.10 to 1.12, macOS and ubuntu.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions