-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import deadlock detection causes deadlock #82272
Comments
There seems to be a race condition in importlib._bootstrap._ModuleLock that can cause a deadlock. The sequence of operations is as follows:
The issue was found in pypy3 but it also affects all the recent CPython versions I tried. diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index f167c84..7f7188e 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -435,10 +435,15 @@ class ImportTests(unittest.TestCase):
os.does_not_exist
def test_concurrency(self):
+ def delay_has_deadlock(frame, event, arg):
+ if event == 'call' and frame.f_code.co_name == 'has_deadlock':
+ time.sleep(0.2)
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'data'))
try:
exc = None
def run():
+ sys.settrace(delay_has_deadlock)
event.wait()
try:
import package |
I ported the fix from 6daa37f for 3.6 and 3.8 shipped with SLE 15SP2 and openSUSE Tumbleweed, but it seems that this fix doesn't help. Here is the part of py-bt I see each time: (gdb) py-bt
Traceback (most recent call first):
File "<frozen importlib._bootstrap>", line 107, in acquire
File "<frozen importlib._bootstrap>", line 158, in __enter__
File "<frozen importlib._bootstrap>", line 595, in _exec
File "<frozen importlib._bootstrap>", line 271, in _load_module_shim
File "<frozen importlib._bootstrap_external>", line 852, in load_module
File "<frozen importlib._bootstrap_external>", line 1027, in load_module
File "<frozen importlib._bootstrap_external>", line 1034, in _check_name_wrapper
File "/usr/lib/python3.8/site-packages/salt/loader.py", line 4779, in _load_module
File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1926, in _inner_load
if self._load_module(name) and key in self._dict:
File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2193, in _load
File "/usr/lib/python3.8/site-packages/salt/utils/lazy.py", line 99, in __getitem__
if self._load(key):
File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1283, in __getitem__
func = super().__getitem__(item)
File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1139, in __getitem__
return self._dict[key + self.suffix]
File "/usr/lib/python3.8/site-packages/salt/template.py", line 495, in check_render_pipe_str
File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1428, in render
f_noext,
File "/usr/lib/python3.8/site-packages/salt/pillar/__init__.py", line 781, in __init__
... |
I just saw a buildbot failure that might be related to the test added in #17518:
|
This removes the unused negative_dictoffset function: the type this function would create is available as _testcapi.HeapCTypeWithNegativeDict
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: