New submission from STINNER Victor: While trying to reproduce a race condition in asyncio, I got an assertion error from the Python garbage collector at exit. It's not easy to reproduce the issue: run attached script on Python 3.4 compiled in debug mode (to get assertions) and press CTRL+c twice. It looks like the bug occurs more often after at least 400 runs.
The Future class of the asyncio may store an exception in its private Future._exception attribute. An exception stores a traceback. I don't know if it's related. Output: --- ... run #347 ^CTraceback (most recent call last): File "x.py", line 73, in <module> main() File "x.py", line 70, in main el.join() File "/home/haypo/prog/python/default/Lib/threading.py", line 1061, in join self._wait_for_tstate_lock() File "/home/haypo/prog/python/default/Lib/threading.py", line 1077, in _wait_for_tstate_lock elif lock.acquire(block, timeout): run #348 KeyboardInterrupt ... run #364 run #365 run #366 run #367 -cancelled- run #368 ^CException ignored in: <module 'threading' from '/home/haypo/prog/python/default/Lib/threading.py'> Traceback (most recent call last): File "/home/haypo/prog/python/default/Lib/threading.py", line 1295, in _shutdown t.join() File "/home/haypo/prog/python/default/Lib/threading.py", line 1061, in join self._wait_for_tstate_lock() File "/home/haypo/prog/python/default/Lib/threading.py", line 1077, in _wait_for_tstate_lock elif lock.acquire(block, timeout): KeyboardInterrupt -cancelled- python: Modules/gcmodule.c:379: visit_decref: Assertion `((gc)->gc.gc_refs >> (1)) != 0' failed. Abandon (core dumped) $ ls *core python-6564.core $ gdb ./python -c python-6564.core Core was generated by `./python x.py'. Program terminated with signal SIGABRT, Aborted. (gdb) where #0 0x0000003f3a835c59 in raise () from /lib64/libc.so.6 #1 0x0000003f3a837368 in abort () from /lib64/libc.so.6 #2 0x0000003f3a82ebb6 in __assert_fail_base () from /lib64/libc.so.6 #3 0x0000003f3a82ec62 in __assert_fail () from /lib64/libc.so.6 #4 0x000000000043ac66 in visit_decref ( op=Frame 0x7f013c001398, for file x.py, line 43, in task (self=<WorkerThread(_kwargs={}, loop=<_UnixSelectorEventLoop(_scheduled=[], _default_executor=None, _running=True, _ready=<collections.deque at remote 0x7f014bbed6e0>, _selector=<EpollSelector(_map=<_SelectorMapping(_selector=<...>) at remote 0x7f014c3bff60>, _epoll=<select.epoll at remote 0x7f014d5bce08>, _fd_to_key={5: <SelectorKey at remote 0x7f014bbecaf8>}) at remote 0x7f014c3bfae8>, _granularity=<float at remote 0x7f014e8c76b8>, _ssock=<socket at remote 0x7f014c3c5a78>, _internal_fds=1, _csock=<socket at remote 0x7f014bbeb5f8>, _signal_handlers={}) at remote 0x7f014c437400>, _is_stopped=False, _target=None, _daemonic=False, executor=<ThreadPoolExecutor(_max_workers=5, _shutdown=False, _work_queue=<Queue(not_empty=<Condition(release=<built-in method release of _thread.lock object at remote 0x7f014c3bb1a0>, acquire=<built-in method acquire of _thread.lock object at remote 0x7f014c3bb1a0>, _lock=<_thread.lock at remote 0x 7f014c3bb1a0>, _waiters=<collecti...(truncated), data=0x0) at Modules/gcmodule.c:379 #5 0x00000000004336bd in tb_traverse (tb=0x7f01493a66e8, visit=0x43abb4 <visit_decref>, arg=0x0) at Python/traceback.c:64 #6 0x000000000043acdc in subtract_refs (containers=0x8f1a20 <generations+64>) at Modules/gcmodule.c:398 #7 0x000000000043bdee in collect (generation=2, n_collected=0x7fff499317c0, n_uncollectable=0x7fff499317b8, nofail=0) at Modules/gcmodule.c:957 #8 0x000000000043c455 in collect_with_callback (generation=2) at Modules/gcmodule.c:1128 #9 0x000000000043d1d5 in PyGC_Collect () at Modules/gcmodule.c:1604 #10 0x000000000041e959 in Py_Finalize () at Python/pythonrun.c:605 #11 0x000000000043a890 in Py_Main (argc=2, argv=0x22bb020) at Modules/main.c:771 #12 0x000000000041aba9 in main (argc=2, argv=0x7fff49931ab8) at ./Modules/python.c:69 (gdb) frame 4 #4 0x000000000043ac66 in visit_decref ( (gdb) print op $3 = Frame 0x7f013c001398, for file x.py, line 43, in task (self=<WorkerThread(_kwargs={}, loop=<_UnixSelectorEventLoop(_scheduled=[], _default_executor=None, _running=True, _ready=<collections.deque at remote 0x7f014bbed6e0>, _selector=<EpollSelector(_map=<_SelectorMapping(_selector=<...>) at remote 0x7f014c3bff60>, _epoll=<select.epoll at remote 0x7f014d5bce08>, _fd_to_key={5: <SelectorKey at remote 0x7f014bbecaf8>}) at remote 0x7f014c3bfae8>, _granularity=<float at remote 0x7f014e8c76b8>, _ssock=<socket at remote 0x7f014c3c5a78>, _internal_fds=1, _csock=<socket at remote 0x7f014bbeb5f8>, _signal_handlers={}) at remote 0x7f014c437400>, _is_stopped=False, _target=None, _daemonic=False, executor=<ThreadPoolExecutor(_max_workers=5, _shutdown=False, _work_queue=<Queue(not_empty=<Condition(release=<built-in method release of _thread.lock object at remote 0x7f014c3bb1a0>, acquire=<built-in method acquire of _thread.lock object at remote 0x7f014c3bb1a0>, _lock=<_thread.lock at remote 0x7f 014c3bb1a0>, _waiters=<collecti...(truncated) --- ---------- messages: 210368 nosy: gvanrossum, haypo, pitrou, serhiy.storchaka priority: normal severity: normal status: open title: python: Modules/gcmodule.c:379: visit_decref: Assertion `((gc)->gc.gc_refs >> (1)) != 0' failed. type: crash versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20526> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com