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 — long_subtype_new underallocates for zero · Issue #101037 · python/cpython

long_subtype_new underallocates for zero #101037

New issue
Copy link
New issue
Copy link
Closed
#101038
Closed
long_subtype_new underallocates for zero#101037
#101038
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@mdickinson
mdickinson
opened on Jan 14, 2023
Issue body actions

When creating int instances, we always allocate space for and initialise at least one digit, since the medium_value function that's used for fast paths assumes the existence of that digit. This change was introduced for Python 3.11 in PR #27832.

However, the corresponding change in long_subtype_new was missed; this results in us asking for zero digits in the case of creating an instance of a subclass of int with value zero - e.g.,

class MyInt(int):
    pass

myint = MyInt()  # problem

That's then a problem if myint is used in a context where medium_value might be called on it, for example as in int(myint).

We've got away with this so far because of a compensating overallocation issue: see #81381; this bug blocked an attempt to address #81381 in #100855. But I believe this should still be fixed.

I'll make a PR shortly.

Linked PRs

  • gh-101037: Fix potential memory underallocation for zeros of int subtypes #101038
  • [3.11] gh-101037: Fix potential memory underallocation for zeros of int subtypes (GH-101038) #101219

Activity

  1. mdickinson
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    3.11only security fixesonly security fixes
    3.12only security fixesonly security fixes
    on Jan 14, 2023
  2. mdickinson
    added a commit that references this issue on Jan 14, 2023

    pythongh-101037: Fix memory allocation for zeros of int subtypes

    ee51432
  3. corona10
    added a commit that references this issue on Jan 19, 2023

    pythongh-101037: Fix memory allocation for zeros of int subtypes

    61adba0
  4. mdickinson
    closed this as completedin #101038on Jan 21, 2023
  5. mdickinson
    added a commit that references this issue on Jan 21, 2023

    gh-101037: Fix potential memory underallocation for zeros of int subt…

    401fdf9
  6. miss-islington
    added a commit that references this issue on Jan 21, 2023

    pythongh-101037: Fix potential memory underallocation for zeros of in…

    c1a9d27
  7. mdickinson
    added a commit that references this issue on Jan 21, 2023

    [3.11] gh-101037: Fix potential memory underallocation for zeros of i…

    d2aaf81
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.11only security fixesonly security fixes3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    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.