Skip to content

Incorrect cleanup of async_context_threadsafe_background.c #3178

Open

Description

@kilograham

Noticed when reviewing code for #3179, the cleanup here is incorrect subject to race (or at least unlucky timing) conditions, and is also not correct for custom alarm pools.. see comments in the source file.

Activity

  1. added this to the 2.3.2 milestone on Sep 5, 2026
  2. self-assigned this
    on Sep 5, 2026
  3. kilograham commented on Sep 5, 2026

    @kilograham
    ContributorAuthor
  4. kvnloo commented on Sep 29, 2026

    @kvnloo

    I think this is worth testing as a lifecycle invariant rather than patching one cleanup path in isolation.

    I'd exercise:

    • the default alarm pool
    • a custom alarm pool
    • teardown while an alarm is pending
    • teardown while the background worker is active
    • repeated init/deinit
    • callbacks racing with the final teardown

    The useful acceptance condition seems to be: after async_context_deinit() returns, no callback associated with that context can execute and no alarm remains registered against either the default or custom pool.

    That should make it easier to tell whether the fix belongs in async_context_threadsafe_background_deinit() itself or in the underlying alarm-worker removal contract.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions