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: `_Pointer.contents` setter casts a `__class__`-spoofed value to `CDataObject *` · Issue #161390 · python/cpython

ctypes: _Pointer.contents setter casts a __class__-spoofed value to CDataObject * #161390

New issue
Copy link
New issue
Copy link
Open
Open
ctypes: _Pointer.contents setter casts a __class__-spoofed value to CDataObject *#161390
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-ctypestype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

@theosotr
theosotr
opened on Nov 5, 2026
Issue body actions

Bug report

Summary

Assigning to a ctypes pointer's .contents crashes the interpreter with SIGSEGV if the value is an ordinary Python object that claims to be the right type.

Expected: a TypeError, from a type check that does not consult __class__.

Reproducer

import ctypes

class Forge:
    __slots__ = ("a", "b", "c", "d")
    __class__ = ctypes.c_int

    def __init__(self):
        self.a = ctypes.c_int(7)
        self.b = self.c = self.d = None

ctypes.pointer(ctypes.c_int(1)).contents = Forge()
Segmentation fault (core dumped)

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Linked PRs

  • gh-161390: Reject non-ctypes objects assigned to pointer contents #161402

Activity

  1. theosotr
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 5, 2026
  2. sobolevn
    added
    topic-ctypes
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    and removed
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 5, 2026
  3. makwana-akshat commented on Nov 5, 2026

    @makwana-akshat
    makwana-akshat
    on Nov 5, 2026
    More actions

    i would like to solve this issue. assign/

  4. rajorin
    added a commit that references this issue on Nov 5, 2026

    pythongh-161390: Avoid an unresolved contents reference in the NEWS e…

    9815024
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

    extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-ctypestype-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.