New submission from Xinmeng Xia <xi...@smail.nju.edu.cn>:

This program is initially from 
"cpython/Lib/test/crashers/warnings_del_crasher.py" in Python 2.7. The original 
case is fixed for all version of Python and removed from "crashers" directory. 
However, if we replace the statement  "for i in range(10):" of original program 
 with the statement "for do_work in range(10):" . The race will happen again, 
and it will crash Python 3.7 - 3.10.
==================================================
import threading
import warnings

class WarnOnDel(object):
    def __del__(self):
        warnings.warn("oh no something went wrong", UserWarning)

def do_work():
    while True:
        w = WarnOnDel()

-for i in range(10):
+for do_work in range(10):
    t = threading.Thread(target=do_work)
    t.setDaemon(1)
    t.start()
=================================================


Error messages on Python 3.7-3.10:
-------------------------------------------------------------------------------
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/python310/lib/python3.10/threading.py", line 960, in 
_bootstrap_inner
Exception in thread Thread-3:
Traceback (most recent call last):
Exception in thread Thread-4:
  File "/usr/local/python310/lib/python3.10/threading.py", line 960, in 
_bootstrap_inner
Exception in thread Thread-5:
Traceback (most recent call last):
    self.run()
Traceback (most recent call last):
    self.run()
Exception in thread Thread-6:
Exception in thread Thread-8:
Exception in thread Thread-9:
Exception in thread Thread-10:
Fatal Python error: _enter_buffered_busy: could not acquire lock for 
<_io.BufferedWriter name='<stderr>'> at interpreter shutdown, possibly due to 
daemon threads
Python runtime state: finalizing (tstate=0x2679180)

Current thread 0x00007f3481d3a700 (most recent call first):
<no Python frame>
Aborted (core dumped)

----------
components: Interpreter Core
messages: 383883
nosy: xxm
priority: normal
severity: normal
status: open
title: Exposing a race in the "_warnings" resulting Python parser crash
type: crash
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42763>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to