Repository navigation
s390x RHEL7 got crash on the refleak test #102351
Copy link
Copy link
Closed
Labels
type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
link: https://buildbot.python.org/all/#/builders/217/builds/1082/steps/5/logs/stdio
test_multiple_watchers (test.test_capi.test_watchers.TestFuncWatchers.test_multiple_watchers) ... ok
./Include/object.h:654: _Py_NegativeRefcount: Assertion failed: object has negative ref count
<object at 0x3ff7e7ffd80 is freed>
Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized
Current thread 0x000003ff86cf7700 (most recent call first):
Garbage-collecting
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/support/__init__.py", line 2085 in _hook
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/setup.py", line 84 in _test_audit_hook
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/test_capi/test_watchers.py", line 479 in test_watcher_raises_error
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/case.py", line 579 in _callTestMethod
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/case.py", line 623 in run
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/case.py", line 678 in __call__
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 122 in run
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 84 in __call__
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 122 in run
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 84 in __call__
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 122 in run
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 84 in __call__
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 122 in run
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 84 in __call__
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 122 in run
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/suite.py", line 84 in __call__
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/unittest/runner.py", line 208 in run
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/support/__init__.py", line 1104 in _run_suite
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/support/__init__.py", line 1230 in run_unittest
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/runtest.py", line 281 in _test_module
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/refleak.py", line 89 in dash_R
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/runtest.py", line 315 in _runtest_inner2
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/runtest.py", line 360 in _runtest_inner
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/runtest.py", line 235 in _runtest
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/runtest.py", line 265 in runtest
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/main.py", line 353 in rerun_failed_tests
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/main.py", line 756 in _main
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/main.py", line 711 in main
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/libregrtest/main.py", line 775 in main
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/test/__main__.py", line 2 in <module>
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/runpy.py", line 88 in _run_code
File "/home/dje/cpython-buildarea/pull_request.edelsohn-rhel-z.refleak/build/Lib/runpy.py", line 198 in _run_module_as_main
Extension modules: _testcapi, _testmultiphase, _testsinglephase, _testinternalcapi (total: 4)
make: *** [buildbottest] Aborted
program finished with exit code 2Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Activity
[-]s390x RHEL7 got crash on the refleak test.[/-][+]s390x RHEL7 got crash on the refleak test[/+]corona10 commentedon Mar 1, 2023
I will try to debug issue with QEMU..
corona10 commentedon Mar 1, 2023
Okay no way to setup through QEMU since I can not get the image of s390x RHEL image.
So I will try to contract with the machine manager.
corona10 commentedon Mar 1, 2023
And also @vstinner share useful approach for this issue: https://pythondev.readthedocs.io/debug_tools.html#debug-crash-in-garbage-collection-visit-decref
iritkatriel commentedon Mar 1, 2023
@erlend-aasland
I've reproduced it on a Mac and bisected to:
iritkatriel commentedon Mar 1, 2023
But I think it may be a red herring (when I touch stuff the crash goes away). Maybe we just need to bump the magic number.
pythongh-102351: bump MAGIC_NUMBER
iritkatriel commentedon Mar 1, 2023
I suspect this PR needed the magic number bump: #101933
iritkatriel commentedon Mar 1, 2023
Bumping magic number didn't solve this: #102359.
erlend-aasland commentedon Mar 2, 2023
@iritkatriel, thanks for the heads-up, I'll have a look!
erlend-aasland commentedon Mar 2, 2023
@iritkatriel: what's your repro on macOS? I can't reproduce it (yet) on my M1 running Ventura 13.1.
iritkatriel commentedon Mar 2, 2023
I was running
python -m test -j2 -R3:3 test_capirunning just a submodule of test_capi didn’t fail. I think something to do with module import/setup?
corona10 commentedon Mar 2, 2023
When I debug the recount: -2459565876494606883
It could be overflowed issue or an uninitialized issue.
corona10 commentedon Mar 2, 2023
Ah it's because already freed.
iritkatriel commentedon Mar 2, 2023
I think it might be the same issue as #102350.
I narrowed it down to that test, and if I update my branch with that last commit the crash is gone.
corona10 commentedon Mar 2, 2023
Ah for my case, it's still happening with the latest commit.
iritkatriel commentedon Mar 2, 2023
Clean build?
corona10 commentedon Mar 2, 2023
Yes with the clean-build.
Please read my comment when I triggered the refleak test with the PR.
#102350 (comment)
This issue was created from the comment.
iritkatriel commentedon Mar 2, 2023
Yes, I just got the crash again with main too. Sorry about the noise.
iritkatriel commentedon Mar 2, 2023
I think the problem comes from test_watcher_raises_error in Lib/test/test_capi/test_watchers.py.
This test registers a dictionary watcher which raises an exception. That takes us to
_PyErr_WriteUnraisableMsg, wherePy_DECREF(hook_args);fails because the last item in hook_args (theobj, i.e., the dictionary) has refcnt 0.This only happens when I run it with
./python.exe -m test -v -j2 -R3:3 test_capi. If I remove the-j2it doesn't fail.I added
assert(Py_REFCNT((PyObject*)mp) > 0);at the beginning of_PyDict_NotifyEvent, and it failed (during make)which seem wrong(apparently this is fine, for PyDict_EVENT_DEALLOCATED events).carljm commentedon Mar 3, 2023
Further debugging confirmed that the root cause of this issue is #102381. Fixing all code/func/dict dealloc callbacks to temporarily resurrect the object before calling the callback, and to not save references to the object in unraisablehook, makes this issue go away.
carljm commentedon Mar 3, 2023
For posterity: the specific repro here requiring
-j2 -Rseems to be an artifact of those options causing a GC run to tend to occur while an error-raising func watcher is active, and that GC run deallocates a cycle of unrelated objects from thedatetime.pypure-Python fallbacks, including some functions.carljm commentedon Mar 8, 2023
Fixed in #102382