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 — _PyEval_SetTrace() fails with RuntimeError: Cannot install a trace function while another trace function is being installed · Issue #98257 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
_PyEval_SetTrace() fails with RuntimeError: Cannot install a trace function while another trace function is being installed#98257
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@vstinner
vstinner
opened on Oct 14, 2022
Issue body actions

The test_concurrency() of test_import fails randomly on sys.settrace(). Example:

$ ./python -m test test_import -m test_concurrency -v -j30 -F --fail-env-changed 
(...)
0:00:13 load avg: 12.46 [ 97/1] test_import failed (env changed)
test_concurrency (test.test_import.ImportTests) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.487s

OK
Warning -- Uncaught thread exception: RuntimeError
Exception in thread Thread-13 (run):
Traceback (most recent call last):
  File "/home/vstinner/python/3.10/Lib/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/vstinner/python/3.10/Lib/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/vstinner/python/3.10/Lib/test/test_import/__init__.py", line 457, in run
    sys.settrace(None)
RuntimeError: Cannot install a trace function while another trace function is being installed
(...)

The problem is that the _PyEval_SetTrace() function fails with RuntimeError("Cannot install a trace function while another trace function is being installed") on Py_XDECREF(traceobj); indirectly calls sys.settrace().

IMO Py_XDECREF(traceobj); should be called after reentrant = 0;, at the end of the function.

Activity

  1. vstinner
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Oct 14, 2022
  2. vstinner
    added a commit that references this issue on Oct 19, 2022

    gh-98257: Make _PyEval_SetTrace() reentrant (#98258)

    a8fe4bb
  3. vstinner commented on Oct 19, 2022

    @vstinner
    vstinner
    on Oct 19, 2022
    MemberAuthor
    More actions

    Fixed by a8fe4bb

  4. vstinner
    closed this as completedon Oct 19, 2022
  5. carljm
    added a commit that references this issue on Oct 20, 2022

    Merge branch 'main' into typewatch

    8bba5da
  6. pvliesdonk
    added a commit that references this issue on Aug 19, 2026

    test: fence writer trace-hook install before builder start in sync-re…

    320d781
  7. sentrivana
    added a commit that references this issue on Oct 14, 2026

    test(litellm): Require filelock>=4.0.3 on Python 3.10/3.11 (#8026)

    c96bbef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.