-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
gh-94510: Raise on re-entrant calls to sys.setprofile and sys.settrace #94511
Conversation
pablogsal
commented
Jul 2, 2022
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: sys.settrace and sys.setprofile are not re-entrant #94510
Py_XINCREF(arg); | ||
Py_XDECREF(traceobj); |
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 reversed this order to avoid dec-refing too much traceobj
if traceobj
and arg
are the same objects and we held the last ref.
@@ -750,7 +750,7 @@ profiler_dealloc(ProfilerObject *op) | |||
if (op->flags & POF_ENABLED) { | |||
PyThreadState *tstate = _PyThreadState_GET(); | |||
if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) { | |||
PyErr_WriteUnraisable((PyObject *)op); | |||
_PyErr_WriteUnraisableMsg("When destroying _lsprof profiler", NULL); |
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.
Interestigly, I catched this bug with the change: the object here is dead so is not correct to pass it to the unraisable hook.
Thanks @pablogsal for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry @pablogsal and @ambv, I had trouble checking out the |
Sorry, @pablogsal and @ambv, I could not cleanly backport this to |
…d sys.settrace (pythonGH-94511) Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 40d81fd) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
GH-94578 is a backport of this pull request to the 3.11 branch. |
GH-94579 is a backport of this pull request to the 3.10 branch. |
…d sys.settrace (pythonGH-94511) Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 40d81fd) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
…d sys.settrace (pythonGH-94511) Co-authored-by: Łukasz Langa <lukasz@langa.pl>. (cherry picked from commit 40d81fd) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>