Title: sqlite3: set_trace_callback/set_progress_handler/set_authorizer race conditions free-threaded build · Issue #162299 · python/cpython · GitHub
Open Graph Title: sqlite3: set_trace_callback/set_progress_handler/set_authorizer race conditions free-threaded build · Issue #162299 · python/cpython
X Title: sqlite3: set_trace_callback/set_progress_handler/set_authorizer race conditions free-threaded build · Issue #162299 · python/cpython
Description: Bug report The three mentioned callback contexts have no syncronisation such that on free threading builds we can see double decref or a use after free. // Modules/_sqlite/connection.c static void set_callback_context(callback_context **...
Open Graph Description: Bug report The three mentioned callback contexts have no syncronisation such that on free threading builds we can see double decref or a use after free. // Modules/_sqlite/connection.c static void ...
X Description: Bug report The three mentioned callback contexts have no syncronisation such that on free threading builds we can see double decref or a use after free. // Modules/_sqlite/connection.c static void ...
Opengraph URL: https://github.com/python/cpython/issues/162299
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlite3: set_trace_callback/set_progress_handler/set_authorizer race conditions free-threaded build","articleBody":"### Bug report\n\nThe three mentioned callback contexts have no syncronisation such that on free threading builds we can see double decref or a use after free. \n\n```c\n// Modules/_sqlite/connection.c\nstatic void\nset_callback_context(callback_context **ctx_pp, callback_context *ctx)\n{\n callback_context *tmp = *ctx_pp;\n *ctx_pp = ctx;\n if (tmp != NULL) {\n decref_callback_context(tmp);\n }\n}\n```\n\nThis small reproduction reliably crashes even on standard free-threaded build\n\n```python\nimport sqlite3\nimport sys\nimport threading\n\ncx = sqlite3.connect(\":memory:\", check_same_thread=False)\ncb = lambda *args: 0\n\nsetters = {\n \"trace\": lambda: cx.set_trace_callback(cb),\n \"progress\": lambda: cx.set_progress_handler(cb, 1),\n \"authorizer\": lambda: cx.set_authorizer(cb),\n}\nset_callback = setters[sys.argv[1] if len(sys.argv) > 1 else \"trace\"]\n\ndef setter():\n for _ in range(20000):\n set_callback()\n\ndef user():\n for _ in range(2000):\n cx.execute(\"select 1\").fetchall()\n\nthreads = [threading.Thread(target=setter) for _ in range(4)]\nthreads.append(threading.Thread(target=user))\nfor t in threads:\n t.start()\nfor t in threads:\n t.join()\nprint(\"no crash\")\n```\n\nFrom what I could see there's no an open issue for this!\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS","author":{"url":"https://github.com/johng","@type":"Person","name":"johng"},"datePublished":"2026-11-19T23:10:43Z","url":"https://github.com/python/cpython/issues/162299"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:af5d0f7d-d305-f916-44e0-79c81f538a75 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A488:3B07B3:1B000:219FC:6B01E936 |
| html-safe-nonce | 61f35d5c4eb6597eeb61e45d489d0224e038f14336daaac4a267c82ff6d0b0a3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDg4OjNCMDdCMzoxQjAwMDoyMTlGQzo2QjAxRTkzNiIsInZpc2l0b3JfaWQiOiIyODA5OTg2NDQ0MDEyMTUzMTQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3476d214c886a1a16a6616b329db66e6588793271bc370b233117aba8f11da85 |
| hovercard-subject-tag | issue:6500940847 |
| 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/162299/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d5f63e45e80e542e747c99d3d746e560db51dff997674b84e20e3dcd5af82ef8/python/cpython/issues/162299 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d5f63e45e80e542e747c99d3d746e560db51dff997674b84e20e3dcd5af82ef8/python/cpython/issues/162299 |
| og:image:alt | Bug report The three mentioned callback contexts have no syncronisation such that on free threading builds we can see double decref or a use after free. // Modules/_sqlite/connection.c static void ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | johng |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width