Skip to content

intern_static() never detects a failed _Py_hashtable_set() (< -1 should be < 0) #157892

Description

@eendebakpt

Bug report

Bug description:

In intern_static() in Objects/unicodeobject.c, the result of _Py_hashtable_set() is compared with < -1:

if (_Py_hashtable_set(INTERNED_STRINGS, s, s) < -1) {
)

_Py_hashtable_set() (Python/hashtable.c) returns 0 on success and -1 when the entry allocation fails, so this condition is never true and the Py_FatalError() call is unreachable.

The check has been like this since gh-120520, so 3.13, 3.14 and main are affected.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on Sep 21, 2026
  2. Vara715 commented on Sep 27, 2026

    @Vara715

    hey, can i work on this one?

  3. pochmann commented on Sep 27, 2026

    @pochmann
    Contributor

    @Vara715 Why? What's wrong with the already existing PR? What would you do differently?

  4. added a commit that references this issue on Sep 27, 2026
  5. added a commit that references this issue on Sep 29, 2026
  6. added a commit that references this issue on Sep 29, 2026
  7. added a commit that references this issue on Oct 10, 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

    easyinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions