Skip to content

_testinternalcapi.get_counter_optimizer() segfaults #108727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iritkatriel opened this issue Aug 31, 2023 · 1 comment · Fixed by #108734
Closed

_testinternalcapi.get_counter_optimizer() segfaults #108727

iritkatriel opened this issue Aug 31, 2023 · 1 comment · Fixed by #108734
Assignees
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@iritkatriel
Copy link
Member

iritkatriel commented Aug 31, 2023

Crash report

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Output from running 'python -VV' on the command line:

Python 3.13.0a0 (heads/main:13a00078b8, Aug 31 2023, 18:44:11) [Clang 14.0.3 (clang-1403.0.22.14.1)]

What happened?

# cat zz.py                        
__lltrace__ = True

import _testinternalcapi

def f():
    _testinternalcapi.get_counter_optimizer()

f()

Error messages

% ./python.exe zz.py               

Resuming frame for 'f' in module '__main__'
    stack=[]
0: RESUME 0
    stack=[]
2: LOAD_GLOBAL 0
    stack=[<module at 0x1073f2150>]
12: LOAD_ATTR 2
    stack=[<builtin_function_or_method at 0x1073f3650>]
32: PUSH_NULL
    stack=[<builtin_function_or_method at 0x1073f3650>, <nil>]
34: CALL 0
    stack=[<Counter optimizer at 0x1073a47c0>]
42: POP_TOP
zsh: segmentation fault  ./python.exe zz.py

Linked PRs

@iritkatriel iritkatriel added the type-crash A hard crash of the interpreter, possibly with a core dump label Aug 31, 2023
@iritkatriel
Copy link
Member Author

This seems to fix it:

--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -289,6 +289,7 @@ static PyTypeObject CounterOptimizer_Type = {
     .tp_itemsize = 0,
     .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
     .tp_methods = counter_methods,
+    .tp_dealloc = (destructor)PyObject_Del,
 };
 
 PyObject *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
2 participants