Skip to content
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

Merged
merged 3 commits into from
Jul 5, 2022

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jul 2, 2022

Py_XINCREF(arg);
Py_XDECREF(traceobj);
Copy link
Member Author

@pablogsal pablogsal Jul 2, 2022

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.

@pablogsal pablogsal marked this pull request as draft July 2, 2022 20:48
@pablogsal pablogsal marked this pull request as ready for review July 3, 2022 00:15
@@ -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);
Copy link
Member Author

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.

@ambv ambv merged commit 40d81fd into python:main Jul 5, 2022
@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry @pablogsal and @ambv, I had trouble checking out the 3.11 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 40d81fd63b46cf998880ce3bf3e5cb42bc3199c1 3.11

@miss-islington
Copy link
Contributor

Sorry, @pablogsal and @ambv, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 40d81fd63b46cf998880ce3bf3e5cb42bc3199c1 3.10

ambv pushed a commit to ambv/cpython that referenced this pull request Jul 5, 2022
…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>
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 5, 2022
@bedevere-bot
Copy link

GH-94578 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 5, 2022
@bedevere-bot
Copy link

GH-94579 is a backport of this pull request to the 3.10 branch.

ambv pushed a commit to ambv/cpython that referenced this pull request Jul 5, 2022
…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>
pablogsal added a commit to pablogsal/cpython that referenced this pull request Jul 5, 2022
…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>
pablogsal added a commit that referenced this pull request Jul 5, 2022
…ettrace (GH-94511) (#94579)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>.
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
ambv added a commit that referenced this pull request Jul 5, 2022
…settrace (GH-94511) (GH-94578)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 40d81fd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants