GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — array module declares Py_MOD_GIL_NOT_USED, but crashes (SIGSEGV) under concurrent access in free-threading builds · Issue #146007 · python/cpython Closed as duplicate Closed as duplicate Copy link Labels extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump DescriptionCrash reportWhat happened?The Build the latest cpython with --disable-gil. Reproducer Code import array import sys import threading if sys._is_gil_enabled(): sys.exit("EXIT: requires --disable-gil build") NUM_THREADS = 4 ITERS = 5_000_000 arr = array.array('i', list(range(10))) def reader(): for _ in range(ITERS): try: _ = arr[0] except IndexError: pass def writer(): for _ in range(ITERS): arr.clear() arr.extend(range(10)) readers = [threading.Thread(target=reader) for _ in range(NUM_THREADS)] writers = [threading.Thread(target=writer) for _ in range(NUM_THREADS)] for t in writers + readers: t.start() for t in writers + readers: t.join() print("COMPLETE: without crash — race may not have triggered this run.") print("Re-run on a multi-core machine, or increase NUM_THREADS / ITERS") When running it, I observed: Exception in thread Thread-5 (writer): Root Cause: Modules/arraymodule.c has no @critical_section annotations and no atomic operations on ob_item. array_resize(0) frees and nulls ob_item without any lock, while array_item reads ob_size and then dereferences ob_item without any lock. The same problem likely affects other methods. CPython versions tested on:3.15 Operating systems tested on:macOS Output from running 'python -VV' on the command line:Python 3.15.0a7+ free-threading build (heads/main:e167e06f8c6, Mar 15 2026, 09:14:39) [Clang 17.0.0 (clang-1700.6.4.2)] Activity
MetadataMetadataAssigneesLabelsextension-modulesC modules in the Modules dirC modules in the Modules dirtopic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump Projects
MilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — 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. |