Skip to content

Race between _PyParkingLot_Park and _PyParkingLot_UnparkAll when handling interrupts #114944

Closed
@mpage

Description

@mpage

Bug report

Bug description:

There is a potential race when _PyParkingLot_UnparkAll is executing in one thread and another thread is unblocked because of an interrupt in _PyParkingLot_Park. Consider the following scenario:

  1. Thread T0 is blocked in _PyParkingLot_Park on address A.
  2. Thread T1 executes _PyParkingLot_UnparkAll on address A. It finds the wait_entry for T0 and unlinks its list node.
  3. Immediately after (2), T0 is woken up due to an interrupt. It then segfaults trying to unlink the node that was previously unlinked in (2).

I haven't attempted to write a minimal repro for this. It occurs reliably on MacOS on this PR when running ./python.exe -m test test_asyncio.test_events --match test_get_event_loop_new_process.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions