GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Free-threaded: concurrent syslog.openlog() and sys.argv[0] assignment crash the interpreter · Issue #159864 · python/cpython

Free-threaded: concurrent syslog.openlog() and sys.argv[0] assignment crash the interpreter #159864

New issue
Copy link
New issue
Copy link
Closed
Closed
Free-threaded: concurrent syslog.openlog() and sys.argv[0] assignment crash the interpreter#159864
Copy link
Labels
topic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

@espressolee
espressolee
opened on Oct 20, 2026
Issue body actions

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 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.

Reading the source on main (4c73f50, 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.

The 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.

Reproducer (run as a separate process; repeat a few times)
import sys
import syslog
import threading
import time

assert not sys._is_gil_enabled(), "needs a free-threaded build with the GIL disabled"

stop = threading.Event()

def reader():
    while not stop.is_set():
        syslog.openlog()

def writer():
    i = 0
    while not stop.is_set():
        i += 1
        sys.argv[0] = f"prog-{i}" + "z" * 24

threads = [threading.Thread(target=reader) for _ in range(3)]
threads.append(threading.Thread(target=writer))
for t in threads:
    t.start()
time.sleep(4)
stop.set()
for t in threads:
    t.join()
syslog.closelog()
print("no crash in 4 s")

Linked PRs

  • gh-159864: Fix syslog.openlog() crash with concurrent sys.argv changes #159884
  • [3.15] gh-159864: Fix syslog.openlog() crash with concurrent sys.argv changes (GH-159884) #159952
  • [3.14] gh-159864: Fix syslog.openlog() crash with concurrent sys.argv changes (GH-159884) #159954

Activity

  1. lazerg commented on Oct 20, 2026

    @lazerg
    lazerg
    on Oct 20, 2026
    Contributor
    More actions

    I can reproduce this on main with a free-threaded debug build. It crashes in syslog_get_argv() on the freed sys.argv[0], and switching to PyList_GetItemRef() fixes it. @espressolee do you want to open the PR, or should I?

  2. espressolee commented on Oct 20, 2026

    @espressolee
    espressolee
    on Oct 20, 2026
    ContributorAuthor
    More actions

    Thanks for confirming it on main and pinning down the cause! I'd like to open the PR, and I'll add you as a co-author. I'll link it here.

  3. aisk
    added
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    topic-free-threading
    on Oct 20, 2026
  4. ZeroIntensity
    added a commit that references this issue on Oct 20, 2026

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

    e5e0748
  5. ZeroIntensity commented on Oct 20, 2026

    @ZeroIntensity
    ZeroIntensity
    on Oct 20, 2026
    Member
    More actions

    Thanks @espressolee for the fix!

  6. ZeroIntensity
    closed this as completedon Oct 20, 2026
  7. ZeroIntensity
    added 2 commits that reference this issue on Oct 20, 2026

    [3.15] gh-159864: Fix syslog.openlog() crash with concurrent sys.argv…

    a11aa06

    [3.14] gh-159864: Fix syslog.openlog() crash with concurrent sys.argv…

    ed5bcda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue 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.