GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-98257: Make _PyEval_SetTrace() reentrant by vstinner · Pull Request #98258 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Oct 14, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Make sys.setprofile() and sys.settrace() functions reentrant. They can no long fail with: RuntimeError("Cannot install a trace function while another trace function is being installed").

Make _PyEval_SetTrace() and _PyEval_SetProfile() functions reentrant, rather than detecting and rejecting reentrant calls. Only delete the reference to function arguments once the new function is fully set, when a reentrant call is safe. Call also _PySys_Audit() earlier.

  • Issue: _PyEval_SetTrace() fails with RuntimeError: Cannot install a trace function while another trace function is being installed #98257

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
vstinner requested a review from markshannon as a code owner October 14, 2022 10:31
@bedevere-bot bedevere-bot added the awaiting core review label Oct 14, 2022
@vstinner
gh-98257: Make _PyEval_SetTrace() reentrant
62bca63
Make sys.setprofile() and sys.settrace() functions reentrant.  They
can no long fail with: RuntimeError("Cannot install a trace function
while another trace function is being installed").

Make _PyEval_SetTrace() and _PyEval_SetProfile() functions reentrant,
rather than detecting and rejecting reentrant calls. Only delete the
reference to function arguments once the new function is fully set,
when a reentrant call is safe. Call also _PySys_Audit() earlier.
@vstinner

vstinner commented Oct 14, 2022

Copy link
Copy Markdown
Member Author

@markshannon @pablogsal: Would you mind to review this change?

The reentrant call introduced by the commit 40d81fd to fix gh-94510:

commit 40d81fd63b46cf998880ce3bf3e5cb42bc3199c1
Author: Pablo Galindo Salgado <[email protected]>
Date:   Tue Jul 5 19:18:47 2022 +0100

    gh-94510: Raise on re-entrant calls to sys.setprofile and sys.settrace (GH-94511)
    
    Co-authored-by: Łukasz Langa <[email protected]>
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Oct 14, 2022
sys.settrace and sys.setprofile are not re-entrant #94510
Closed
@vstinner

vstinner commented Oct 14, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

This change fix #98257 on my Linux machine (without this fix, it takes less than a minute to reproduce it). I interrupted the test after 10 min:

$ ./python -m test test_import -m test_concurrency -j50 -F --fail-env-changed  
(...)
0:09:58 load avg: 51.58 [4904] test_import passed
0:09:58 load avg: 51.58 [4905] test_import passed
0:09:58 load avg: 51.58 [4906] test_import passed
0:09:58 load avg: 51.58 [4907] test_import passed
0:09:58 load avg: 51.58 [4908] test_import passed
0:09:58 load avg: 51.58 [4909] test_import passed
0:09:58 load avg: 51.58 [4910] test_import passed
0:09:58 load avg: 51.58 [4911] test_import passed
^C

I don't see any refleak regression:

$ ./python -m test test_sys_setprofile test_sys_settrace test_import -j3 -R 3:3
(...)
All 3 tests OK.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Update test_sys_settrace and test_sys_setprofile
0568430
JelleZijlstra
JelleZijlstra approved these changes Oct 18, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Oct 18, 2022
@ericsnowcurrently

ericsnowcurrently commented Oct 18, 2022

Copy link
Copy Markdown
Member

CC @brandtbucher

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal
pablogsal approved these changes Oct 18, 2022
View reviewed changes
@vstinner
vstinner merged commit a8fe4bb into python:main Oct 19, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Oct 19, 2022
@vstinner
vstinner deleted the reentrant_settrace branch October 19, 2022 22:31
carljm added a commit to carljm/cpython that referenced this pull request Oct 20, 2022
@carljm
Merge branch 'main' into typewatch
8bba5da
* main: (40 commits)
  pythongh-98461: Fix source location in comprehensions bytecode (pythonGH-98464)
  pythongh-98421: Clean Up PyObject_Print (pythonGH-98422)
  pythongh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments (pythonGH-98462)
  CODEOWNERS: Become a typing code owner (python#98480)
  [doc] Improve logging cookbook example. (pythonGH-98481)
  Add more tkinter.Canvas tests (pythonGH-98475)
  pythongh-95023: Added os.setns and os.unshare functions (python#95046)
  pythonGH-98363: Presize the list for batched() (pythonGH-98419)
  pythongh-98374: Suppress ImportError for invalid query for help() command. (pythongh-98450)
  typing tests: `_overload_dummy` raises `NotImplementedError`, not `RuntimeError` (python#98351)
  pythongh-98354: Add unicode check for 'name' attribute in _imp_create_builtin (pythonGH-98412)
  pythongh-98257: Make _PyEval_SetTrace() reentrant (python#98258)
  pythongh-98414: py.exe launcher does not use defaults for -V:company/ option (pythonGH-98460)
  pythongh-98417: Store int_max_str_digits on the Interpreter State (pythonGH-98418)
  Doc: Remove title text from internal links (python#98409)
  [doc] Refresh the venv introduction documentation, and correct the statement about VIRTUAL_ENV (pythonGH-98350)
  Docs: Bump sphinx-lint and fix unbalanced inline literal markup (python#98441)
  pythongh-92886: Replace assertion statements in `handlers.BaseHandler` to support running with optimizations (`-O`) (pythonGH-93231)
  pythongh-92886: Fix tests that fail when running with optimizations (`-O`) in `_test_multiprocessing.py` (pythonGH-93233)
  pythongh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_py_compile.py` (pythonGH-93235)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@pablogsal pablogsal pablogsal approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@vstinner @ericsnowcurrently @JelleZijlstra @pablogsal @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.