Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CallingPy_DECREF twice does not result in error with debug build #109496

Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@kevinAlbs

Description

@kevinAlbs

Bug report

Bug description:

Documented behavior of Py_REF_DEBUG includes:

Py_REF_DEBUG also checks after every decref to verify that the refcount hasn't
gone negative, and causes an immediate fatal error if it has.

CallingPy_DECREF twice does not result in the expected error:

staticPyObject*spam_double_decref(PyObject*self,PyObject*args) {printf("spam_double_decref ... begin\n");PyObject*obj=Py_BuildValue("s","foobar");Py_DECREF (obj);Py_DECREF (obj);// Expect error, but does not error when using cpython built with `--with-pydebug`.printf("spam_double_decref ... end\n");Py_RETURN_NONE;}

To reproduce:

Build CPython with--with-pydebug:

cd /home/kevin/code/cpythonmkdir debugcd debug/../configure --with-pydebugmake -j16

Buildthis sample extension callingPy_DECREF twice using the debug build of CPython:

PYTHON=/home/kevin/code/cpython/debug/python$PYTHON setup.py build

Run a test with this extension:

# Add path to built extension to `PYTHONPATH`.export PYTHONPATH=/home/kevin/code/cpython/KEVINALBS/double_decref_extension/build/lib.linux-x86_64-cpython-313-pydebugPYTHON=/home/kevin/code/cpython/debug/python$PYTHON -c"import spam; spam.double_decref()"# Prints:# spam_double_decref ... begin# spam_double_decref ... end

No error is indicated, but an error is expected.

Extension source is located here:https://github.com/kevinAlbs/double_decref_extension
Tested with cpython main branch on commit:929cc4e.

If this issue is confirmed, I may be interested to investigate possible solutions.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-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


      [8]ページ先頭

      ©2009-2025 Movatter.jp