Skip to content

Conversation

ericsnowcurrently
Copy link
Member

@ericsnowcurrently ericsnowcurrently commented Nov 21, 2024

The new lock may be used instead of the global "HEAD" lock. That global lock guards the list of interpreters, but unfortunately in some situations (like for interp->threads.head) it has been used as a generic "lock everything". This change helps us move away from that situation.

Note that there are 3 places in pystate.c where we have left HEAD_LOCK()/HEAD_UNLOCK() in place:

  • interpreter_clear()
  • new_threadstate()
  • tstate_delete_common()

Otherwise we end up breaking a constraint on free-threaded builds.

Co-authored-by: RUANG (James Roy) [email protected]

@ericsnowcurrently
Copy link
Member Author

There's a bit of code in tstate_delete_common() to avoid a deadlock, but I'm sure it isn't right. It probably makes sense to use a recursive lock here. I'm going to look more closely.

@ericsnowcurrently
Copy link
Member Author

Ideally we could build on top of gh-127121 for the recursive lock.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant