-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
gh-105766: Add Locking Around Custom Allocators #105619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fcbeb6d
fbe26eb
7191629
dd60989
0f2a242
321d1c2
52c01ea
a213597
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -586,6 +586,7 @@ static PyStatus | |
| init_interp_create_gil(PyThreadState *tstate, int own_gil) | ||
| { | ||
| PyStatus status; | ||
| _PyRuntimeState *runtime = tstate->interp->runtime; | ||
|
|
||
| /* finalize_interp_delete() comment explains why _PyEval_FiniGIL() is | ||
| only called here. */ | ||
|
|
@@ -603,6 +604,9 @@ init_interp_create_gil(PyThreadState *tstate, int own_gil) | |
| if (_PyStatus_EXCEPTION(status)) { | ||
| return status; | ||
| } | ||
| HEAD_LOCK(runtime); | ||
| runtime->allocators.num_gils++; | ||
|
||
| HEAD_UNLOCK(runtime); | ||
|
|
||
| return _PyStatus_OK(); | ||
| } | ||
|
|
@@ -1730,6 +1734,11 @@ finalize_interp_delete(PyInterpreterState *interp) | |
| /* Cleanup auto-thread-state */ | ||
| _PyGILState_Fini(interp); | ||
|
|
||
| _PyRuntimeState *runtime = interp->runtime; | ||
| HEAD_LOCK(runtime); | ||
| runtime->allocators.num_gils--; | ||
|
||
| HEAD_UNLOCK(runtime); | ||
|
|
||
| /* We can't call _PyEval_FiniGIL() here because destroying the GIL lock can | ||
| fail when it is being awaited by another running daemon thread (see | ||
| bpo-9901). Instead pycore_create_interpreter() destroys the previously | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest
unsigned int