Title: Free-threaded: concurrent syslog.openlog() and sys.argv[0] assignment crash the interpreter · Issue #159864 · python/cpython · GitHub
Open Graph Title: Free-threaded: concurrent syslog.openlog() and sys.argv[0] assignment crash the interpreter · Issue #159864 · python/cpython
X Title: Free-threaded: concurrent syslog.openlog() and sys.argv[0] assignment crash the interpreter · Issue #159864 · python/cpython
Description: On the free-threaded build, calling syslog.openlog() (without ident) in several threads while another thread assigns sys.argv[0] crashes the interpreter with SIGSEGV. I ran the script below as a separate process (python3.14t repro.py, 5 ...
Open Graph Description: On the free-threaded build, calling syslog.openlog() (without ident) in several threads while another thread assigns sys.argv[0] crashes the interpreter with SIGSEGV. I ran the script below as a se...
X Description: On the free-threaded build, calling syslog.openlog() (without ident) in several threads while another thread assigns sys.argv[0] crashes the interpreter with SIGSEGV. I ran the script below as a se...
Opengraph URL: https://github.com/python/cpython/issues/159864
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Free-threaded: concurrent syslog.openlog() and sys.argv[0] assignment crash the interpreter","articleBody":"On the free-threaded build, calling `syslog.openlog()` (without `ident`) in several threads while another thread assigns `sys.argv[0]` crashes the interpreter with SIGSEGV.\n\nI ran the script below as a separate process (`python3.14t repro.py`, 5 times, default environment) on macOS 27.0.1 arm64 with the python-build-standalone build `cpython-3.14.6+freethreaded-macos-aarch64-none` installed by uv. Every run was killed by a signal: SIGSEGV in 2 runs and SIGTRAP in 3 (shell exit codes 139 and 133). An earlier driver with the same structure (three `openlog()` threads, one writer, 4 s, `PYTHONMALLOC=debug`) crashed 3.14.0rc1, 3.14.6 and 3.15.0b4 in 5 of 5 runs each; only the last 200 characters of stderr were kept from those runs, so they give no crash-site evidence. I have not tested 3.14.8 or `main`.\n\nReading the source on `main` (4c73f50ca9, lines 109–110), `syslog_get_argv()` in `Modules/syslogmodule.c` takes `sys.argv[0]` with `PyList_GetItem()` (a borrowed reference) and increfs it only afterwards. This suggests a possible borrowed-reference lifetime race with a concurrent replacement of `sys.argv[0]`; I have not established that this race causes the observed SIGSEGV. `PyList_GetItemRef()` may address this particular window; I have not validated a patch.\n\nThe same pattern was listed as item 91 of #157197, which was closed for procedural reasons and whose linked gists are gone; I am not aware of another report specifically tracking it.\n\n\u003cdetails>\u003csummary>Reproducer (run as a separate process; repeat a few times)\u003c/summary>\n\n```python\nimport sys\nimport syslog\nimport threading\nimport time\n\nassert not sys._is_gil_enabled(), \"needs a free-threaded build with the GIL disabled\"\n\nstop = threading.Event()\n\ndef reader():\n while not stop.is_set():\n syslog.openlog()\n\ndef writer():\n i = 0\n while not stop.is_set():\n i += 1\n sys.argv[0] = f\"prog-{i}\" + \"z\" * 24\n\nthreads = [threading.Thread(target=reader) for _ in range(3)]\nthreads.append(threading.Thread(target=writer))\nfor t in threads:\n t.start()\ntime.sleep(4)\nstop.set()\nfor t in threads:\n t.join()\nsyslog.closelog()\nprint(\"no crash in 4 s\")\n```\n\n\u003c/details>\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159884\n* gh-159952\n* gh-159954\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/espressolee","@type":"Person","name":"espressolee"},"datePublished":"2026-10-20T07:00:55Z","url":"https://github.com/python/cpython/issues/159864"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:e305124a-f002-9a92-799d-9b85e332fb2e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E264:336727:BF28EF:F9A47C:6AF8583F |
| html-safe-nonce | 2c70799102274eaeca1642752e213fb6359de7170b3bbf5dafbbff5b8dc57e19 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjY0OjMzNjcyNzpCRjI4RUY6RjlBNDdDOjZBRjg1ODNGIiwidmlzaXRvcl9pZCI6IjkyNDE1NzI3NjA0MDIyMjc4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f3596755f80367b39878b9005ce68d8c71ed66799c2be919899ef42d035c3802 |
| hovercard-subject-tag | issue:5937393919 |
| 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/159864/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d1fa8eb78492e7550a0e523c1a9fba21d5ab4fc1c0b37e8a3774b3b668b24c58/python/cpython/issues/159864 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d1fa8eb78492e7550a0e523c1a9fba21d5ab4fc1c0b37e8a3774b3b668b24c58/python/cpython/issues/159864 |
| og:image:alt | On the free-threaded build, calling syslog.openlog() (without ident) in several threads while another thread assigns sys.argv[0] crashes the interpreter with SIGSEGV. I ran the script below as a se... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | espressolee |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| 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 | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width