Skip to content

gh-159864: Fix syslog.openlog() crash with concurrent sys.argv changes - #159884

Merged
ZeroIntensity merged 1 commit into
python:mainfrom
espressolee:gh-159864-syslog-argv
Oct 20, 2026
Merged

ZeroIntensity merged 1 commit into
python:mainfrom
espressolee:gh-159864-syslog-argv

Conversation

@espressolee

@espressolee espressolee commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

syslog_get_argv() took sys.argv[0] with PyList_GetItem() and only increfed it afterwards, so on the free-threaded build another thread replacing sys.argv[0] could free it in between. Use PyList_GetItemRef() instead.

Adds a regression test to test_free_threading.test_syslog that races syslog.openlog() (without ident) against sys.argv[0] assignment.

Thanks to @lazerg for confirming the crash on main and identifying the fix.

Fixes #159864.

…changes

syslog_get_argv() took sys.argv[0] with PyList_GetItem() and increfed it
only afterwards, so on the free-threaded build a concurrent replacement of
sys.argv[0] could free it in between. Use PyList_GetItemRef() instead.

Co-authored-by: Lazizbek Ergashev <[email protected]>
@python-cla-bot

python-cla-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T13:43:10.293424Z 38a30c5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@aisk aisk added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 20, 2026
@ZeroIntensity
ZeroIntensity merged commit e5e0748 into python:main Oct 20, 2026
116 of 118 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @espressolee for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @espressolee and @ZeroIntensity, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker e5e0748abd27e39655cb8dc313a82cad6563c54f 3.14

@bedevere-app

bedevere-app Bot commented Oct 20, 2026

Copy link
Copy Markdown

GH-159952 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 20, 2026
@bedevere-app

bedevere-app Bot commented Oct 20, 2026

Copy link
Copy Markdown

GH-159954 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 20, 2026
@ZeroIntensity

Copy link
Copy Markdown
Member

Congrats on your first contribution :)

ZeroIntensity pushed a commit that referenced this pull request Oct 20, 2026
… changes (GH-159884) (GH-159952)

syslog_get_argv() took sys.argv[0] with PyList_GetItem() and increfed it
only afterwards, so on the free-threaded build a concurrent replacement of
sys.argv[0] could free it in between. Use PyList_GetItemRef() instead.
(cherry picked from commit e5e0748)

Co-authored-by: Junhyung Lee <[email protected]>
Co-authored-by: Lazizbek Ergashev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants