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 — test_thread_state_ensure is flaky on Fedora Linux s390x · Issue #151177 · python/cpython

test_thread_state_ensure is flaky on Fedora Linux s390x #151177

New issue
Copy link
New issue
Copy link
Closed
Closed
test_thread_state_ensure is flaky on Fedora Linux s390x#151177
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@befeleme
befeleme
opened on Jun 9, 2026
Issue body actions

Bug report

Bug description:

test_thread_state_ensure is flaky on Fedora Linux on s390x architecture. Sometimes we see the traceback below:

test_thread_state_ensure (test.test_embed.AuditingTests.test_thread_state_ensure) ... --- ['/builddir/build/BUILD/python3.15-3.15.0_b2-build/Python-3.15.0b2/build/freethreading/Programs/_testembed', 'test_thread_state_ensure'] failed ---
stdout:
stderr:
_testembed: /builddir/build/BUILD/python3.15-3.15.0_b2-build/Python-3.15.0b2/Programs/_testembed.c:2736: test_thread_state_ensure: Assertion `_Py_atomic_load_int(&data.done) == 1' failed.
------
FAIL
======================================================================
FAIL: test_thread_state_ensure (test.test_embed.AuditingTests.test_thread_state_ensure)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/python3.15-3.15.0_b2-build/Python-3.15.0b2/Lib/test/test_embed.py", line 2000, in test_thread_state_ensure
    self.run_embedded_interpreter("test_thread_state_ensure")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/python3.15-3.15.0_b2-build/Python-3.15.0b2/Lib/test/test_embed.py", line 138, in run_embedded_interpreter
    self.assertEqual(p.returncode, returncode,
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
                     "bad returncode %d, stderr is %r" %
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     (p.returncode, err))
                     ^^^^^^^^^^^^^^^^^^^^
AssertionError: -6 != 0 : bad returncode -6, stderr is "_testembed: /builddir/build/BUILD/python3.15-3.15.0_b2-build/Python-3.15.0b2/Programs/_testembed.c:2736: test_thread_state_ensure: Assertion `_Py_atomic_load_int(&data.done) == 1' failed.\n"
----------------------------------------------------------------------

This has been added in #149116
cc @encukou

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Linked PRs

  • gh-151177: Fix race condition in _testembed #151293
  • [3.15] gh-151177: Fix race condition in _testembed (GH-151293) #151312

Activity

  1. befeleme
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jun 9, 2026
  2. picnixz
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    OS-linux
    on Jun 10, 2026
  3. encukou commented on Jun 10, 2026

    @encukou
    encukou
    on Jun 10, 2026
    Member
    More actions

    If you have the box handy, could you test with guarding the write to done, like this?

    diff --git a/Programs/_testembed.c b/Programs/_testembed.c
    index 7246cc06fff..74d0fe37dda 100644
    --- a/Programs/_testembed.c
    +++ b/Programs/_testembed.c
    @@ -2715,8 +2715,8 @@ do_tstate_ensure(void *arg)
         PyThreadState_Release(tokens[2]);
         PyThreadState_Release(tokens[1]);
         PyThreadState_Release(tokens[0]);
    -    PyInterpreterGuard_Close(guard);
         _Py_atomic_store_int(&data->done, 1);
    +    PyInterpreterGuard_Close(guard);
     }
     
     static int

    cc @ZeroIntensity

  4. ZeroIntensity commented on Jun 10, 2026

    @ZeroIntensity
    ZeroIntensity
    on Jun 10, 2026
    Member
    More actions

    If you have the box handy, could you test with guarding the write to done, like this?

    That looks like the right fix.

  5. ZeroIntensity
    removed
    OS-linux
    on Jun 11, 2026
  6. ZeroIntensity commented on Jun 11, 2026

    @ZeroIntensity
    ZeroIntensity
    on Jun 11, 2026
    Member
    More actions

    I put up a fix using Petr's suggested change (#151293). This isn't specific to Linux or Fedora; it's just a general race condition in the test case.

  7. encukou
    added a commit that references this issue on Jun 11, 2026

    gh-151177: Fix race condition in `_testembed` (GH-151293)

    f9ffca3
  8. ZeroIntensity
    added a commit that references this issue on Jun 11, 2026

    [3.15] gh-151177: Fix race condition in `_testembed` (GH-151293) (GH-…

    491768d
  9. ZeroIntensity
    closed this as completedon Jun 11, 2026
  10. encukou commented on Jun 11, 2026

    @encukou
    encukou
    on Jun 11, 2026
    Member
    More actions

    Thanks!

  11. philthompson10
    added a commit that references this issue on Jun 17, 2026

    pythongh-151177: Fix race condition in `_testembed` (pythonGH-151293)

    a406230
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

    testsTests in the Lib/test dirTests in the Lib/test dirtype-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.