Skip to content

Should atexit_hooks be guarded during _atexit? #49841

Closed
@NHDaly

Description

@NHDaly

Two questions, following up from #49774:

  1. Is it safe to grab a mutex inside _atexit()? @kpamnany and I were worried about the system being in an undefined state during shutdown, and we aren't sure if we're allowed to grab a mutex. My hope/guess is yes it's fine? But want to confirm.
  2. Is it possible for user tasks to still be scheduled during _atexit()?
    • If the user tasks can still be running, they might be adding new atexit_hooks while we are popping them and running them, which would be a data race.
    • If that's possible, we need to @lock atexit_hooks_lock inside _atexit().
    • My preference would be to lock it, either way, just to be safe, assuming 1. is resolved.

Questions best answered by: @vtjnash, @vchuravy, @gbaraldi?

Metadata

Metadata

Assignees

No one assigned

    Labels

    multithreadingBase.Threads and related functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions