GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing github.com — gh-154431: Use existing `runtime->audit_hooks.mutex` instead of a new one by sobolevn · Pull Request #154494 · python/cpython Conversation
|
|
I don't think that we actually concurrenly add hooks with both |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Agreed, but why make this change at all? We're just increasing pressure on a lock for no reason. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Because we can't backport the fix with interpreter state changed due to ABI change. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| PyInterpreterState *interp = tstate->interp; | ||
| PyMutex mutex = interp->audit_hooks_mutex; | ||
| PyMutex mutex = interp->runtime->audit_hooks.mutex; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Hi, I noticed the mutex here is copied by value onto the stack, then being locked. I'm worried this subtly changes the semantics into locking a stack-local object instead. The typical usage may be to lock the address directly, i.e. PyMutex_Lock(&interp->runtime->audit_hooks.mutex);
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here is a demo shows locking a stack-local mutex won't affect the real mutex.
#include <Python.h> #include <stdio.h> static PyMutex shared = {0}; int main(void) { PyMutex mutex = shared; PyMutex_Lock(&mutex); printf("locked the COPY: shared=%d copy=%d\n", PyMutex_IsLocked(&shared), PyMutex_IsLocked(&mutex)); PyMutex_Unlock(&mutex); PyMutex_Lock(&shared); printf("locked the FIELD: shared=%d\n", PyMutex_IsLocked(&shared)); PyMutex_Unlock(&shared); return 0; }
Run gcc mutex_copy_demo.c -I Include -I . libpython3.16.a -lpthread -lm -ldl -lutil -o demo && ./demo then it print
locked the COPY: shared=0 copy=1
locked the FIELD: shared=1
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
!buildbot CentOS9.NoGIL.Refleaks |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @encukou for commit 8adcde5 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F154494%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.