gh-98354: Add unicode check for 'name' attribute in _imp_create_builtin by chgnrdv · Pull Request #98412 · python/cpython
Is this intermittent (depending on the order of tests?
It can depend on the order of tests, since it crashes when I run the test package in default order, but passes the CI (which, AFAIK, runs tests in random order).
If I run test_imp separately, it doesn't crash (and passes, as it should).
Furthermore, if you are still seeing the behavior from #98354 in some cases
I don't see the behaviour which I had to fix by this PR anymore and I'm sure that this issue or my fix itself can't cause any problem like this. I think that it is somehow related to how test package handles the import of builtins module in my test case.
Test package output with traceback and abort message:
0:33:04 load avg: 0.83 [190/437] test_imp
Modules/gcmodule.c:113: gc_decref: Assertion "gc_get_refs(g) > 0" failed: refcount is too small
Enable tracemalloc to get the memory block allocation traceback
object address : 0x7f83fbfcb8f0
object refcount : 99
object type : 0x559bf783d860
object type name: module
object repr : <module 'builtins' (built-in)>
Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized
Current thread 0x00007f83fc323740 (most recent call first):
Garbage-collecting
File "/home/.../cpython/Lib/test/support/__init__.py", line 738 in gc_collect
File "/home/.../cpython/Lib/test/libregrtest/save_env.py", line 314 in __exit__
File "/home/.../cpython/Lib/test/libregrtest/runtest.py", line 312 in _runtest_inner2
File "/home/.../cpython/Lib/test/libregrtest/runtest.py", line 360 in _runtest_inner
File "/home/.../cpython/Lib/test/libregrtest/runtest.py", line 235 in _runtest
File "/home/.../cpython/Lib/test/libregrtest/runtest.py", line 265 in runtest
File "/home/.../cpython/Lib/test/libregrtest/main.py", line 450 in run_tests_sequential
File "/home/.../cpython/Lib/test/libregrtest/main.py", line 564 in run_tests
File "/home/.../cpython/Lib/test/libregrtest/main.py", line 742 in _main
File "/home/.../cpython/Lib/test/libregrtest/main.py", line 701 in main
File "/home/.../cpython/Lib/test/libregrtest/main.py", line 763 in main
File "/home/.../cpython/Lib/test/__main__.py", line 2 in <module>
File "/home/.../cpython/Lib/runpy.py", line 88 in _run_code
File "/home/.../cpython/Lib/runpy.py", line 198 in _run_module_as_main
Extension modules: _testcapi, _xxsubinterpreters, _testinternalcapi, _testbuffer, _testmultiphase, _ctypes_test, xxsubtype (total: 7)
Aborted (core dumped)
Stack trace:
#0 0x00007f5d903b134c in __pthread_kill_implementation () from /usr/lib/libc.so.6 #1 0x00007f5d903644b8 in raise () from /usr/lib/libc.so.6 #2 0x00007f5d9034e534 in abort () from /usr/lib/libc.so.6 #3 0x000055faf5565bf6 in fatal_error_exit (status=<optimized out>) at Python/pylifecycle.c:2629 #4 0x000055faf5567236 in fatal_error (fd=2, header=header@entry=1, prefix=prefix@entry=0x55faf56427e0 <__func__.2> "_PyObject_AssertFailed", msg=msg@entry=0x55faf5642646 "_PyObject_AssertFailed", status=status@entry=-1) at Python/pylifecycle.c:2810 #5 0x000055faf55672a0 in _Py_FatalErrorFunc (func=func@entry=0x55faf56427e0 <__func__.2> "_PyObject_AssertFailed", msg=msg@entry=0x55faf5642646 "_PyObject_AssertFailed") at Python/pylifecycle.c:2826 #6 0x000055faf547f0b7 in _PyObject_AssertFailed (obj=0x7f5d8ffc7890, expr=expr@entry=0x55faf56a3268 "gc_get_refs(g) > 0", msg=msg@entry=0x55faf5642692 "refcount is too small", file=file@entry=0x55faf56a30d6 "Modules/gcmodule.c", line=line@entry=113, function=function@entry=0x55faf56a36e8 <__func__.27> "gc_decref") at Objects/object.c:2361 #7 0x000055faf559f22d in gc_decref (g=<optimized out>) at Modules/gcmodule.c:113 #8 0x000055faf559f945 in visit_decref (op=0x7f5d8ffc7890, parent=0x7f5d890a3950) at Modules/gcmodule.c:459 #9 0x000055faf5467b25 in dict_traverse (op=<optimized out>, visit=0x55faf559f8e2 <visit_decref>, arg=0x7f5d890a3950) at Objects/dictobject.c:3525 #10 0x000055faf559df22 in subtract_refs (containers=containers@entry=0x55faf5883018 <_PyRuntime+69432>) at Modules/gcmodule.c:478 #11 0x000055faf559f329 in deduce_unreachable (base=base@entry=0x55faf5883018 <_PyRuntime+69432>, unreachable=unreachable@entry=0x7ffe797ee710) at Modules/gcmodule.c:1103 #12 0x000055faf559feb5 in gc_collect_main (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, generation=generation@entry=2, n_collected=n_collected@entry=0x7ffe797ee798, n_uncollectable=n_uncollectable@entry=0x7ffe797ee7a0, nofail=nofail@entry=0) at Modules/gcmodule.c:1229 #13 0x000055faf55a0431 in gc_collect_with_callback (tstate=0x55faf589e3e0 <_PyRuntime+180992>, generation=2) at Modules/gcmodule.c:1403 #14 0x000055faf55a0513 in gc_collect_impl (module=module@entry=0x7f5d8f7707d0, generation=generation@entry=2) at Modules/gcmodule.c:1541 #15 0x000055faf55a05d3 in gc_collect (module=0x7f5d8f7707d0, args=<optimized out>, args@entry=0x7f5d9062e980, nargs=nargs@entry=0, kwnames=kwnames@entry=0x0) at Modules/clinic/gcmodule.c.h:139 #16 0x000055faf551d845 in _PyEval_EvalFrameDefault (tstate=0x55faf589e3e0 <_PyRuntime+180992>, frame=0x7f5d9062e920, throwflag=0) at Python/ceval.c:4502 #17 0x000055faf5520c0e in _PyEval_EvalFrame (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, frame=frame@entry=0x7f5d9062e830, throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:88 #18 0x000055faf5520d26 in _PyEval_Vector (tstate=0x55faf589e3e0 <_PyRuntime+180992>, func=0x7f5d8f7b9ff0, locals=locals@entry=0x0, args=0x7f5d9062e7f8, argcount=<optimized out>, kwnames=<optimized out>) at Python/ceval.c:5826 #19 0x000055faf5431288 in _PyFunction_Vectorcall (func=<optimized out>, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:396 #20 0x000055faf5433c86 in _PyObject_VectorcallTstate (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, callable=callable@entry=0x7f5d8f7b9ff0, args=args@entry=0x7f5d9062e7f8, nargsf=nargsf@entry=4, kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:92 #21 0x000055faf5433e4f in method_vectorcall (method=<optimized out>, args=0x7f5d9062e800, nargsf=<optimized out>, kwnames=0x0) at Objects/classobject.c:59 #22 0x000055faf54315f9 in _PyObject_VectorcallTstate (tstate=0x55faf589e3e0 <_PyRuntime+180992>, callable=callable@entry=0x7f5d88cbf770, args=args@entry=0x7f5d9062e800, nargsf=9223372036854775811, kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:92 #23 0x000055faf54316c5 in PyObject_Vectorcall (callable=callable@entry=0x7f5d88cbf770, args=args@entry=0x7f5d9062e800, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at Objects/call.c:300 #24 0x000055faf551c178 in _PyEval_EvalFrameDefault (tstate=0x55faf589e3e0 <_PyRuntime+180992>, frame=0x7f5d9062e778, throwflag=0) at Python/ceval.c:4206 #25 0x000055faf5520c0e in _PyEval_EvalFrame (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, frame=frame@entry=0x7f5d9062e290, throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:88 #26 0x000055faf5520d26 in _PyEval_Vector (tstate=0x55faf589e3e0 <_PyRuntime+180992>, func=0x7f5d8f7c8310, locals=locals@entry=0x0, args=0x7f5d8ffbe200, argcount=<optimized out>, kwnames=<optimized out>) at Python/ceval.c:5826 #27 0x000055faf5431288 in _PyFunction_Vectorcall (func=<optimized out>, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:396 #28 0x000055faf5433c86 in _PyObject_VectorcallTstate (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, callable=callable@entry=0x7f5d8f7c8310, args=args@entry=0x7f5d8ffbe200, nargsf=nargsf@entry=1, kwnames=kwnames@entry=0x7f5d8fe68550) at ./Include/internal/pycore_call.h:92 #29 0x000055faf5433e4f in method_vectorcall (method=<optimized out>, args=0x7f5d8ffbe208, nargsf=<optimized out>, kwnames=0x7f5d8fe68550) at Objects/classobject.c:59 #30 0x000055faf5430ee1 in _PyVectorcall_Call (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, func=0x55faf5433d0e <method_vectorcall>, callable=callable@entry=0x7f5d8fe8d1f0, tuple=tuple@entry=0x55faf5882d20 <_PyRuntime+68672>, kwargs=kwargs@entry=0x7f5d8fdf9d30) at Objects/call.c:258 #31 0x000055faf54311d0 in _PyObject_Call (tstate=0x55faf589e3e0 <_PyRuntime+180992>, callable=callable@entry=0x7f5d8fe8d1f0, args=args@entry=0x55faf5882d20 <_PyRuntime+68672>, kwargs=kwargs@entry=0x7f5d8fdf9d30) at Objects/call.c:329 #32 0x000055faf5431218 in PyObject_Call (callable=callable@entry=0x7f5d8fe8d1f0, args=args@entry=0x55faf5882d20 <_PyRuntime+68672>, kwargs=kwargs@entry=0x7f5d8fdf9d30) at Objects/call.c:356 #33 0x000055faf550d9a3 in do_call_core (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, func=func@entry=0x7f5d8fe8d1f0, callargs=callargs@entry=0x55faf5882d20 <_PyRuntime+68672>, kwdict=kwdict@entry=0x7f5d8fdf9d30, use_tracing=0) at Python/ceval.c:6759 #34 0x000055faf551efa4 in _PyEval_EvalFrameDefault (tstate=0x55faf589e3e0 <_PyRuntime+180992>, frame=0x7f5d9062e210, throwflag=0) at Python/ceval.c:4776 #35 0x000055faf5520c0e in _PyEval_EvalFrame (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>,frame=frame@entry=0x7f5d9062e1b8, throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:88 #36 0x000055faf5520d26 in _PyEval_Vector (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>,func=func@entry=0x7f5d8ff83c20, locals=locals@entry=0x7f5d8fdf94f0, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:5826 #37 0x000055faf5520e3c in PyEval_EvalCode (co=co@entry=0x7f5d8fe34640, globals=globals@entry=0x7f5d8fdf94f0, locals=locals@entry=0x7f5d8fdf94f0) at Python/ceval.c:583 #38 0x000055faf550721f in builtin_exec_impl (module=module@entry=0x7f5d8ffc7890, source=0x7f5d8fe34640, globals=0x7f5d8fdf94f0, locals=0x7f5d8fdf94f0, closure=0x0) at Python/bltinmodule.c:1079 #39 0x000055faf550733a in builtin_exec (module=0x7f5d8ffc7890, args=<optimized out>, args@entry=0x7f5d9062e180, nargs=nargs@entry=2, kwnames=kwnames@entry=0x0) at Python/clinic/bltinmodule.c.h:543 #40 0x000055faf547ab58 in cfunction_vectorcall_FASTCALL_KEYWORDS (func=0x7f5d8ffc7ef0, args=0x7f5d9062e180, nargsf=<optimized out>, kwnames=0x0) at Objects/methodobject.c:443 #41 0x000055faf54315f9 in _PyObject_VectorcallTstate (tstate=0x55faf589e3e0 <_PyRuntime+180992>, callable=callable@entry=0x7f5d8ffc7ef0, args=args@entry=0x7f5d9062e180, nargsf=9223372036854775810, kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:92 #42 0x000055faf54316c5 in PyObject_Vectorcall (callable=callable@entry=0x7f5d8ffc7ef0, args=args@entry=0x7f5d9062e180, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at Objects/call.c:300 #43 0x000055faf551c178 in _PyEval_EvalFrameDefault (tstate=0x55faf589e3e0 <_PyRuntime+180992>, frame=0x7f5d9062e0d8, throwflag=0) at Python/ceval.c:4206 #44 0x000055faf5520c0e in _PyEval_EvalFrame (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, frame=frame@entry=0x7f5d9062e020, throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:88 #45 0x000055faf5520d26 in _PyEval_Vector (tstate=0x55faf589e3e0 <_PyRuntime+180992>, func=0x7f5d8fe726d0, locals=locals@entry=0x0, args=0x7f5d8fe686a8, argcount=<optimized out>, kwnames=<optimized out>) at Python/ceval.c:5826 #46 0x000055faf5431288 in _PyFunction_Vectorcall (func=<optimized out>, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:396 #47 0x000055faf5430e33 in _PyVectorcall_Call (tstate=tstate@entry=0x55faf589e3e0 <_PyRuntime+180992>, func=0x55faf5431238 <_PyFunction_Vectorcall>, callable=callable@entry=0x7f5d8fe726d0, tuple=tuple@entry=0x7f5d8fe68690, kwargs=kwargs@entry=0x0) at Objects/call.c:246 #48 0x000055faf54311d0 in _PyObject_Call (tstate=0x55faf589e3e0 <_PyRuntime+180992>, callable=callable@entry=0x7f5d8fe726d0, args=args@entry=0x7f5d8fe68690, kwargs=kwargs@entry=0x0) at Objects/call.c:329 #49 0x000055faf5431218 in PyObject_Call (callable=callable@entry=0x7f5d8fe726d0, args=args@entry=0x7f5d8fe68690, kwargs=kwargs@entry=0x0) at Objects/call.c:356 #50 0x000055faf559cf4d in pymain_run_module (modname=<optimized out>, set_argv0=set_argv0@entry=1) at Modules/main.c:300 #51 0x000055faf559da6e in pymain_run_python (exitcode=exitcode@entry=0x7ffe797ef5d4) at Modules/main.c:604 #52 0x000055faf559dd56 in Py_RunMain () at Modules/main.c:689 #53 0x000055faf559ddcd in pymain_main (args=args@entry=0x7ffe797ef630) at Modules/main.c:719 #54 0x000055faf559de93 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:743 #55 0x000055faf53a2762 in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:15