GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Deadlock caused by type_lock_prevent_release() · Issue #155400 · python/cpython Closed Labels 3.15bugs and security fixesbugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:The current implementation of The suggested fix is to prevent release of both held by the top critical section. Reproducer (note it depends on the memory addresses of the mutexes so not 100% reliable). def test_concurrent_setattr_deadlock(): # two threads assigning to a special method of the same # class could deadlock. One thread held the type lock and waited for # the type dict mutex, which its critical section had released when it # blocked on the stop-the-world mutex, while the other held the type # dict mutex and waited for the type lock. class Base: pass N = 2000 done = False def setter(): func = lambda self: "x" while not done: Base.__repr__ = func try: del Base.__repr__ except AttributeError: pass def subclasser(): while not done: type('Sub', (Base,), {})() def lister(): while not done: Base.__subclasses__() def basesetter(): nonlocal done for i in range(N): if i % 100 == 0: print(i) class A: pass class C: pass class B(A): pass B.__bases__ = (C,) done = True # The setter threads are the ones that deadlock. The others are there # to keep the type lock and the stop-the-world mutex contended, which # is what gets the setters into the window where it happens. targets = ( setter, setter, subclasser, subclasser, lister, lister, basesetter, ) threads = [Thread(target=target) for target in targets] for t in threads: t.start() for t in threads: t.join() CPython versions tested on:CPython main branch Operating systems tested on:Linux Linked PRsActivity
MetadataMetadataAssigneesLabels3.15bugs and security fixesbugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error Projects
MilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |