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 — ctypes: crash when deleting Pointer.contents on the free-threaded build · Issue #156124 · python/cpython

ctypes: crash when deleting Pointer.contents on the free-threaded build #156124

New issue
Copy link
New issue
Copy link
Closed
Closed
ctypes: crash when deleting Pointer.contents on the free-threaded build#156124
Copy link
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesextension-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

Description

@serhiy-storchaka
serhiy-storchaka
opened on Aug 20, 2026
Issue body actions

Crash report

del ptr.contents crashes the free-threaded build.

>>> from ctypes import POINTER, c_int
>>> ptr = POINTER(c_int)(c_int(42))
>>> del ptr.contents
Segmentation fault

Pointer_set_contents() passes the new value to Py_BEGIN_CRITICAL_SECTION2(), which dereferences it to get the mutex, but the value is NULL when the attribute is deleted. The check for NULL is in Pointer_set_contents_lock_held(), which is only called after the critical section is entered.

With the GIL it raises TypeError: Pointer does not support item deletion.

The critical section was added in gh-128182, so this affects 3.14 and newer.

Linked PRs

  • gh-156124: Fix a crash when deleting ctypes Pointer.contents #156125
  • [3.15] gh-156124: Fix a crash when deleting ctypes Pointer.contents (GH-156125) #156153
  • [3.14] gh-156124: Fix a crash when deleting ctypes Pointer.contents (GH-156125) #156154

Activity

  1. serhiy-storchaka
    added
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    3.16new features, bugs and security fixesnew features, bugs and security fixes
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    topic-free-threading
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    on Aug 20, 2026
  2. serhiy-storchaka
    added a parent issue on Aug 20, 2026
    • Add tests for setting and deleting attributes defined in C #156106
  3. serhiy-storchaka
    added a commit that references this issue on Aug 21, 2026

    gh-156124: Fix a crash when deleting ctypes Pointer.contents (GH-156125)

    ca6e733
  4. serhiy-storchaka
    closed this as completedon Aug 21, 2026
  5. serhiy-storchaka
    added a commit that references this issue on Aug 21, 2026

    [3.14] gh-156124: Fix a crash when deleting ctypes Pointer.contents (G…

    a434d87
  6. serhiy-storchaka
    added a commit that references this issue on Oct 10, 2026

    [3.15] gh-156124: Fix a crash when deleting ctypes Pointer.contents (G…

    7681a44
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

    3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesextension-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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

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