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 — assertion failures and a crash when using an uninitialized struct.Struct object · Issue #75960 · python/cpython

assertion failures and a crash when using an uninitialized struct.Struct object #75960

New issue
Copy link
New issue
Copy link
Closed as duplicate
#94532
Closed as duplicate
assertion failures and a crash when using an uninitialized struct.Struct object#75960
#94532
Copy link
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

orenmn
mannequin
opened on Oct 13, 2017
Issue body actions
BPO 31779
Nosy @mdickinson, @meadori, @berkerpeksag, @serhiy-storchaka, @orenmn, @izbyshev, @iritkatriel
PRs
  • bpo-31779: Prevent assertion failures and a crash when using an uninitialized struct.Struct object #3984
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2017-10-13.10:54:20.321>
    labels = ['extension-modules', '3.10', '3.9', 'type-crash', '3.11']
    title = 'assertion failures and a crash when using an uninitialized struct.Struct object'
    updated_at = <Date 2021-10-19.10:22:17.196>
    user = 'https://github.com/orenmn'

    bugs.python.org fields:

    activity = <Date 2021-10-19.10:22:17.196>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2017-10-13.10:54:20.321>
    creator = 'Oren Milman'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31779
    keywords = ['patch']
    message_count = 3.0
    messages = ['304328', '325462', '404285']
    nosy_count = 7.0
    nosy_names = ['mark.dickinson', 'meador.inge', 'berker.peksag', 'serhiy.storchaka', 'Oren Milman', 'izbyshev', 'iritkatriel']
    pr_nums = ['3984']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue31779'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. orenmn commented on Oct 13, 2017

      @orenmn
      orenmnmannequin
      on Oct 13, 2017
      MannequinAuthor
      More actions

      The following code causes an assertion failure:
      import _struct
      struct_obj = _struct.Struct.__new__(_struct.Struct)
      struct_obj.iter_unpack(b'foo')

      This is because Struct_iter_unpack() (in Modules/_struct.c) assumes that
      Struct.init() was called, and so it does assert(self->s_codes != NULL);.

      The same happens in (almost) every method of Struct, and in s_get_format(), so
      in all them, too, we would get an assertion failure in case of an uninitialized
      Struct object.
      The exception is sizeof(), which doesn't have an assert, and simply
      crashes while trying to iterate over self->s_codes.

      I would open a PR to fix this soon.

    2. orenmn
      added
      3.7 (EOL)end of lifeend of life
      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
      on Oct 13, 2017
    3. izbyshev commented on Sep 15, 2018

      @izbyshev
      izbyshevmannequin
      on Sep 15, 2018
      Mannequin
      More actions

      What are the drawbacks of moving all code from __init__ to __new__, at least in master branch (3.8)? IMO it's much more robust than playing whack-a-mole both with ref/memleaks caused by repeated calls to __init__ and absence of initialization checks in all methods.

    4. izbyshev
      added
      3.8 (EOL)end of lifeend of life
      on Sep 15, 2018
    5. iritkatriel commented on Oct 19, 2021

      @iritkatriel
      iritkatriel
      on Oct 19, 2021
      Member
      More actions

      Reproduced on 3.11.

    6. iritkatriel
      added
      3.9 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      3.11only security fixesonly security fixes
      and removed
      3.7 (EOL)end of lifeend of life
      3.8 (EOL)end of lifeend of life
      on Oct 19, 2021
    7. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    8. kumaraditya303
      added
      3.12only security fixesonly security fixes
      and removed
      3.9 (EOL)end of lifeend of life
      on Jul 3, 2022
    9. kumaraditya303
      self-assigned this
      on Jul 3, 2022
    10. mdickinson
      closed this as completedin #94532on Sep 25, 2022
    11. mdickinson
      added a commit that references this issue on Sep 25, 2022

      GH-78724: Initialize struct.Struct in __new__ (GH-94532)

      c8c0afc
    12. mdickinson commented on Nov 26, 2023

      @mdickinson
      mdickinson
      on Nov 26, 2023
      Member
      More actions

      Re-opening: the original fix for this issue has been reverted, since it broke code for users in the wild who were subclassing struct.Struct.

    13. mdickinson
      reopened this on Nov 26, 2023
    14. kumaraditya303
      removed their assignment
      on Jul 8, 2025
    15. kumaraditya303
      closed this as a duplicateof _struct.Struct: calling functions without calling __init__ results in SystemError #78724 on Jul 8, 2025
    16. skirpichev
      added a commit that references this issue on Feb 28, 2026

      pythonGH-78724: Initialize struct.Struct in __new__ (pythonGH-94532)

      be9d0d8
    17. serhiy-storchaka
      added this to Struct, memoryview and array issues 🏗️on Jul 13, 2026
    18. github-project-automation
      moved this to Todo in Struct, memoryview and array issues 🏗️on Jul 13, 2026
    19. github-project-automation
      moved this from Todo to Done in Struct, memoryview and array issues 🏗️on Jul 13, 2026
    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.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

      Projects

      • Struct, memoryview and array issues 🏗️
        Status
        Done
        Show more project fields

      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.