Skip to content

test__xxsubinterpreters: test_already_running() crash randomly on Python built with TraceRefs: invalid object chain #107080

Description

@vstinner

AMD64 Arch Linux TraceRefs 3.x: https://buildbot.python.org/all/#/builders/484/builds/3721

Assertion error: Objects/object.c:2235: _Py_ForgetReference: Assertion failed: invalid object chain.

$ ./python -m test -j2 test__xxsubinterpreters test__xxsubinterpreters -m test_already_running -v
(...)
== Python build: debug TraceRefs
(...)
== CPU count: 12
(...)
0:00:00 load avg: 1.19 Run tests in parallel using 2 child processes
0:00:00 load avg: 1.19 [1/2] test__xxsubinterpreters passed
test_already_running (test.test__xxsubinterpreters.RunStringTests.test_already_running) ... ok
(...)

0:00:00 load avg: 1.19 [2/2/1] test__xxsubinterpreters crashed (Exit code -6)
test_already_running (test.test__xxsubinterpreters.RunStringTests.test_already_running) ...

Objects/object.c:2235: _Py_ForgetReference: Assertion failed: invalid object chain
Enable tracemalloc to get the memory block allocation traceback

object address  : 0x7f01d0be95a0
object refcount : 0
object type     : 0xa1dc00
object type name: str
object repr     : <refcnt 0 at 0x7f01d0be95a0>

Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized

Current thread 0x00007f01df4a1740 (most recent call first):
  <no Python frame>
(...)

Python built with:

git clean -fdx
./configure --with-pydebug --with-trace-refs CFLAGS="-O0"
make -j14

Linked PRs

Activity

  1. changed the title [-]test__xxsubinterpreters: test_already_running() crash randomly on Python built with TraceRefs[/-] [+]test__xxsubinterpreters: test_already_running() crash randomly on Python built with TraceRefs: invalid object chain[/+] on Jul 22, 2023
  2. vstinner commented on Jul 22, 2023

    @vstinner
    MemberAuthor

    The object chain is invalid:

    (gdb) frame
    #13 0x000000000055e731 in _Py_ForgetReference (op=(None, None, None)) at Objects/object.c:2235
    2235	        _PyObject_ASSERT_FAILED_MSG(op, "invalid object chain");
    
    (gdb) l
    2230	    }
    2231	
    2232	    if (op == &refchain ||
    2233	        op->_ob_prev->_ob_next != op || op->_ob_next->_ob_prev != op)
    2234	    {
    2235	        _PyObject_ASSERT_FAILED_MSG(op, "invalid object chain");
    2236	    }
    2237	
    2238	#ifdef SLOW_UNREF_CHECK
    2239	    PyObject *p;
    
    (gdb) p op->_ob_prev->_ob_next != op
    $14 = 1
    
    (gdb) p op->_ob_next->_ob_prev != op
    $15 = 1
    
  3. vstinner commented on Jul 22, 2023

    @vstinner
    MemberAuthor

    Similar error in test_interpreters.test_create_many_threaded():

    $ ./python -m test test_interpreters -m test_create_many_threaded -v
    (...)
    test_create_many_threaded (test.test_interpreters.StressTests.test_create_many_threaded) ...
    
    Objects/object.c:2235: _Py_ForgetReference: Assertion failed: invalid object chain
    (...)
    
  4. vstinner commented on Jul 22, 2023

    @vstinner
    MemberAuthor
  5. ericsnowcurrently commented on Aug 2, 2023

    @ericsnowcurrently
    Member

    --with-trace-refs builds use a C global variable to store the linked list of objects. The problem is that the variable is used by all interpreters. The solution is to make that variable per-interpreter.

  6. added a commit that references this issue on Aug 3, 2023
  7. added a commit that references this issue on Aug 3, 2023
  8. added a commit that references this issue on Aug 3, 2023
  9. added a commit that references this issue on Aug 4, 2023
  10. added a commit that references this issue on Aug 5, 2023
  11. added a commit that references this issue on Aug 7, 2023
  12. added a commit that references this issue on Aug 16, 2023
  13. vstinner commented on Sep 14, 2023

    @vstinner
    MemberAuthor

    serhiy-storchaka reopened this Aug 16, 2023

    @serhiy-storchaka: Hum, is this issue fixed or not?

  14. serhiy-storchaka commented on Sep 14, 2023

    @serhiy-storchaka
    Member

    I reopened it only because the backport to 3.12 was not merged yet. I linked the backport PR to this issue and thought that merging it will automatically close the issue, but it did not happen.

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

Metadata

Metadata

Labels

3.12only security fixes3.13only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-subinterpreterstype-bugAn unexpected behavior, bug, or error

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions