Title: Deadlock in test_opcache with gh-131174 applied · Issue #133130 · python/cpython · GitHub
Open Graph Title: Deadlock in test_opcache with gh-131174 applied · Issue #133130 · python/cpython
X Title: Deadlock in test_opcache with gh-131174 applied · Issue #133130 · python/cpython
Description: Bug report This is to document the deadlock that occurs with gh-131174 applied. It seems a bit hard to reproduce and I had to repeatedly run the tests. When I got it to finally deadlock, the stack-trace for the three threads are as follo...
Open Graph Description: Bug report This is to document the deadlock that occurs with gh-131174 applied. It seems a bit hard to reproduce and I had to repeatedly run the tests. When I got it to finally deadlock, the stack-...
X Description: Bug report This is to document the deadlock that occurs with gh-131174 applied. It seems a bit hard to reproduce and I had to repeatedly run the tests. When I got it to finally deadlock, the stack-...
Opengraph URL: https://github.com/python/cpython/issues/133130
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Deadlock in test_opcache with gh-131174 applied","articleBody":"# Bug report\n\nThis is to document the deadlock that occurs with gh-131174 applied. It seems a bit hard to reproduce and I had to repeatedly run the tests. When I got it to finally deadlock, the stack-trace for the three threads are as follows. Note that `update_slots_callback()` runs with the world stopped.\n\nThread 1:\n```\n[...]\n#6 0x000055e8fa1ab214 in _PySemaphore_PlatformWait (sema=sema@entry=0x7ffefa17dda0, timeout=timeout@entry=-1)\n at Python/parking_lot.c:162\n#7 0x000055e8fa1ab55c in _PySemaphore_Wait (sema=sema@entry=0x7ffefa17dda0, timeout=timeout@entry=-1,\n detach=detach@entry=0) at Python/parking_lot.c:232\n#8 0x000055e8fa1ab6e1 in _PyParkingLot_Park (addr=addr@entry=0x55e8fa5a186c \u003c_PyRuntime+361772\u003e,\n expected=expected@entry=0x7ffefa17de24, size=size@entry=4, timeout_ns=timeout_ns@entry=-1,\n park_arg=park_arg@entry=0x0, detach=detach@entry=0) at Python/parking_lot.c:335\n#9 0x000055e8fa1c1c43 in tstate_wait_attach (tstate=tstate@entry=0x55e8fa5a1840 \u003c_PyRuntime+361728\u003e)\n at Python/pystate.c:2145\n#10 0x000055e8fa1c1df0 in _PyThreadState_Attach (tstate=tstate@entry=0x55e8fa5a1840 \u003c_PyRuntime+361728\u003e)\n at Python/pystate.c:2180\n#11 0x000055e8fa17048f in PyEval_AcquireThread (tstate=tstate@entry=0x55e8fa5a1840 \u003c_PyRuntime+361728\u003e)\n at Python/ceval_gil.c:605\n#12 0x000055e8fa1ab56b in _PySemaphore_Wait (sema=sema@entry=0x7ffefa17df00, timeout=timeout@entry=-1,\n detach=detach@entry=1) at Python/parking_lot.c:234\n#13 0x000055e8fa1ab6e1 in _PyParkingLot_Park (addr=addr@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e,\n expected=expected@entry=0x7ffefa17df97, size=size@entry=1, timeout_ns=timeout_ns@entry=-1,\n park_arg=park_arg@entry=0x7ffefa17dfa0, detach=detach@entry=1) at Python/parking_lot.c:335\n#14 0x000055e8fa19fb6a in _PyMutex_LockTimed (m=m@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e, timeout=timeout@entry=-1,\n flags=flags@entry=_PY_LOCK_DETACH) at Python/lock.c:108\n#15 0x000055e8fa1a0970 in PyMutex_Lock (m=m@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e) at Python/lock.c:611\n#16 0x000055e8fa1435c6 in _PyMutex_Lock (m=m@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e) at ./Include/cpython/lock.h:49\n#17 0x000055e8fa14378f in _PyCriticalSection_BeginSlow (c=c@entry=0x7ffefa17e110,\n m=m@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e) at Python/critical_section.c:37\n#18 0x000055e8f9fe8918 in _PyCriticalSection_BeginMutex (c=c@entry=0x7ffefa17e110,\n m=0x55e8fa599160 \u003c_PyRuntime+327200\u003e) at ./Include/internal/pycore_critical_section.h:119\n#19 0x000055e8fa000264 in _PyType_LookupStackRefAndVersion (type=0x7f06d8afc810,\n name=name@entry=0x55e8fa558f28 \u003c_PyRuntime+64488\u003e, out=out@entry=0x7f071b60d190) at Objects/typeobject.c:5891\n[...]\n```\n\nThread 2:\n```\n[...]\n#6 0x000055e8fa1ab214 in _PySemaphore_PlatformWait (sema=sema@entry=0x7f06cc4fd500, timeout=timeout@entry=-1)\n at Python/parking_lot.c:162\n#7 0x000055e8fa1ab55c in _PySemaphore_Wait (sema=sema@entry=0x7f06cc4fd500, timeout=timeout@entry=-1,\n detach=detach@entry=0) at Python/parking_lot.c:232\n#8 0x000055e8fa1ab6e1 in _PyParkingLot_Park (addr=addr@entry=0x72a40000f03c, expected=expected@entry=0x7f06cc4fd584,\n size=size@entry=4, timeout_ns=timeout_ns@entry=-1, park_arg=park_arg@entry=0x0, detach=detach@entry=0)\n at Python/parking_lot.c:335\n#9 0x000055e8fa1c1c43 in tstate_wait_attach (tstate=tstate@entry=0x72a40000f010) at Python/pystate.c:2145\n#10 0x000055e8fa1c1df0 in _PyThreadState_Attach (tstate=tstate@entry=0x72a40000f010) at Python/pystate.c:2180\n#11 0x000055e8fa17048f in PyEval_AcquireThread (tstate=tstate@entry=0x72a40000f010) at Python/ceval_gil.c:605\n#12 0x000055e8fa290c0f in thread_run (boot_raw=boot_raw@entry=0x7214000012d0) at ./Modules/_threadmodule.c:350\n#13 0x000055e8fa1e682d in pythread_wrapper (arg=0x720c00000b80) at Python/thread_pthread.h:242\n#14 0x00007f071c601def in __tsan_thread_start_func (arg=0x7ffefa17dd60)\n at ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1012\n#15 0x00007f071c354aa4 in start_thread (arg=\u003coptimized out\u003e) at ./nptl/pthread_create.c:447\n#16 0x00007f071c3e1c3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78\n[...]\n```\n\nThread 3\n```\n[...]\n#6 0x000055e8fa1ab214 in _PySemaphore_PlatformWait (sema=sema@entry=0x7f06cbcfb4a0, timeout=timeout@entry=-1)\n at Python/parking_lot.c:162\n#7 0x000055e8fa1ab55c in _PySemaphore_Wait (sema=sema@entry=0x7f06cbcfb4a0, timeout=timeout@entry=-1,\n detach=detach@entry=1) at Python/parking_lot.c:232\n#8 0x000055e8fa1ab6e1 in _PyParkingLot_Park (addr=addr@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e,\n expected=expected@entry=0x7f06cbcfb537, size=size@entry=1, timeout_ns=timeout_ns@entry=-1,\n park_arg=park_arg@entry=0x7f06cbcfb540, detach=detach@entry=1) at Python/parking_lot.c:335\n#9 0x000055e8fa19fb6a in _PyMutex_LockTimed (m=m@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e, timeout=timeout@entry=-1,\n flags=flags@entry=_PY_LOCK_DETACH) at Python/lock.c:108\n#10 0x000055e8fa1a0970 in PyMutex_Lock (m=m@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e) at Python/lock.c:611\n#11 0x000055e8fa1435c6 in _PyMutex_Lock (m=m@entry=0x55e8fa599160 \u003c_PyRuntime+327200\u003e) at ./Include/cpython/lock.h:49\n#12 0x000055e8fa143bf5 in _PyCriticalSection_Resume (tstate=tstate@entry=0x72a400019010)\n at Python/critical_section.c:109\n#13 0x000055e8f9f805e2 in _PyCriticalSection_Pop (c=c@entry=0x7f06cbcfb670)\n at ./Include/internal/pycore_critical_section.h:141\n#14 0x000055e8f9f80618 in _PyCriticalSection_End (c=c@entry=0x7f06cbcfb670)\n at ./Include/internal/pycore_critical_section.h:155\n#15 0x000055e8f9f806c7 in ensure_shared_on_read (mp=mp@entry=0x7f06d94e1030) at Objects/dictobject.c:1326\n#16 0x000055e8f9f860a4 in _Py_dict_lookup_threadsafe (mp=mp@entry=0x7f06d94e1030,\n key=key@entry=0x55e8fa5592b8 \u003c_PyRuntime+65400\u003e, hash=hash@entry=5605474849373301295,\n value_addr=value_addr@entry=0x7f06cbcfb740) at Objects/dictobject.c:1497\n#17 0x000055e8f9f86e3f in _PyDict_GetItemRef_KnownHash (op=op@entry=0x7f06d94e1030,\n key=key@entry=0x55e8fa5592b8 \u003c_PyRuntime+65400\u003e, hash=hash@entry=5605474849373301295,\n result=result@entry=0x7f06cbcfb7a0) at Objects/dictobject.c:2370\n#18 0x000055e8f9ffff81 in find_name_in_mro (type=type@entry=0x7f06d9691410, name=0x55e8fa5592b8 \u003c_PyRuntime+65400\u003e,\n error=error@entry=0x7f06cbcfb824) at Objects/typeobject.c:5721\n#19 0x000055e8fa007d9b in update_one_slot (type=type@entry=0x7f06d9691410, p=0x55e8fa5259a0 \u003cslotdefs\u003e)\n at Objects/typeobject.c:11292\n#20 0x000055e8fa007f9b in update_slots_callback (type=type@entry=0x7f06d9691410, data=data@entry=0x7f06cbcfb8c0)\n at Objects/typeobject.c:11390\n[...]\n```\n\nInside the `_PyCriticalSection_Resume` of the 3rd thread, it's waiting on `m1`:\n```\n#12 0x000055e8fa143bf5 in _PyCriticalSection_Resume (tstate=tstate@entry=0x72a400019010)\n at Python/critical_section.c:109\n109 PyMutex_Lock(m1);\n(gdb) l\n104 m2 = c2-\u003e_cs_mutex2;\n105 c2-\u003e_cs_mutex2 = NULL;\n106 }\n107\n108 if (m1) {\n109 PyMutex_Lock(m1);\n110 }\n111 if (m2) {\n112 PyMutex_Lock(m2);\n113 }\n(gdb) p *m1\n$9 = {_bits = 3 '\\003'}\n(gdb) p *m2\n$10 = {_bits = 0 '\\000'}\n```","author":{"url":"https://github.com/nascheme","@type":"Person","name":"nascheme"},"datePublished":"2025-04-29T06:35:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/133130/cpython/issues/133130"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bedb31d6-413f-edd9-ed32-22c07d13572f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD30:36844C:1ACC21D:2533A2F:6A55EA17 |
| html-safe-nonce | 8ee70af8d94a9d48d0f838ee7415c8ac99c635df6edf4e1b7b6f76cfcdf1921d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDMwOjM2ODQ0QzoxQUNDMjFEOjI1MzNBMkY6NkE1NUVBMTciLCJ2aXNpdG9yX2lkIjoiNzMyNDYzMzY2MzU1OTU1OTcwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 36588afe5006bac90ecb275d5a2e40e1b52c73acf8845753575b6023177883d2 |
| hovercard-subject-tag | issue:3027225519 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/133130/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cd5c98ced94c9d30b8bd1ff014aac414b2f26390c489aa8350eb47284ca4bec2/python/cpython/issues/133130 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cd5c98ced94c9d30b8bd1ff014aac414b2f26390c489aa8350eb47284ca4bec2/python/cpython/issues/133130 |
| og:image:alt | Bug report This is to document the deadlock that occurs with gh-131174 applied. It seems a bit hard to reproduce and I had to repeatedly run the tests. When I got it to finally deadlock, the stack-... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nascheme |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3725c7f9b2a6e3a27ef57c5aed13428c0f65e045 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width