python / python/cpython

PyUnstable_Eval_RequestCodeExtraIndex freefunc may be called with a null pointer

Open
#122,491 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

The PyUnstable_Code_SetExtra path checks for the previous value being null but code_dealloc does not.

This can lead to freefunc being called with null either through the extra value being explicitly set to null or through a value being set on an extra value with a later index, without a value being set on an earlier index.

This doesn't match the documentation, which says that freefunc is not called for null values.

CPython versions tested on:

3.11, CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-122492

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Objects/codeobject.c at the PyUnstable_Code_SetExtra check and the code_dealloc path linked in the report. Compare both paths with the documented null-value behavior, then inspect linked PR gh-122492 for the work already underway and its validation approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.