Skip to content

tracemalloc.stop() Can Crash With a Subinterpreter #110029

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

Open
ericsnowcurrently opened this issue Sep 28, 2023 · 1 comment
Open

tracemalloc.stop() Can Crash With a Subinterpreter #110029

ericsnowcurrently opened this issue Sep 28, 2023 · 1 comment
Labels
3.12 only security fixes 3.13 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-subinterpreters type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Sep 28, 2023

Crash report

Reproducer:

import tracemalloc
import _xxsubinterpreters as _interpreters

tracemalloc.start()
interpid = _interpreters.create()
print(tracemalloc.get_traced_memory())
tracemalloc.stop()

It crashes at tracemalloc.stop():

  Id   Target Id         Frame
* 1    Thread 0x7f7584fb5100 (LWP 16763) 0x000055ea735459c9 in _PyObject_DebugDumpAddress (p=0x7f758310cd30) at Objects/obmalloc.c:2409


Thread 1 (Thread 0x7f7584fb5100 (LWP 16763)):
#0  0x000055ea735459c9 in _PyObject_DebugDumpAddress (p=0x7f758310cd30) at Objects/obmalloc.c:2409
#1  0x000055ea73545699 in _PyMem_DebugCheckAddress (func=0x55ea737fb2b0 <__func__.22287> "_PyMem_DebugRawFree", api=114 'r', p=0x7f758310cd30) at Objects/obmalloc.c:2327
#2  0x000055ea735450e8 in _PyMem_DebugRawFree (ctx=0x55ea73c3b188 <_PyRuntime+520>, p=0x7f758310cd30) at Objects/obmalloc.c:2160
#3  0x000055ea73542949 in PyMem_RawFree (ptr=0x7f758310cd30) at Objects/obmalloc.c:686
#4  0x000055ea73544c4c in _PyObject_Free (ctx=0x0, p=0x7f758310cd30) at Objects/obmalloc.c:1854
#5  0x000055ea7354512e in _PyMem_DebugRawFree (ctx=0x55ea73c3b1e8 <_PyRuntime+616>, p=0x7f758310cd40) at Objects/obmalloc.c:2164
#6  0x000055ea735455f7 in _PyMem_DebugFree (ctx=0x55ea73c3b1e8 <_PyRuntime+616>, ptr=0x7f758310cd40) at Objects/obmalloc.c:2297
#7  0x000055ea73542cd3 in PyObject_Free (ptr=0x7f758310cd40) at Objects/obmalloc.c:831
#8  0x000055ea7359ab74 in unicode_dealloc (unicode=<unknown at remote 0x7f758310cd40>) at Objects/unicodeobject.c:1604
#9  0x000055ea73541552 in _Py_Dealloc (op=<unknown at remote 0x7f758310cd40>) at Objects/object.c:2735
#10 0x000055ea7370bf5b in Py_DECREF (filename=0x55ea7386b62e "Python/tracemalloc.c", lineno=776, op=<unknown at remote 0x7f758310cd40>) at ./Include/object.h:672
#11 0x000055ea7370d66f in tracemalloc_clear_filename (value=0x7f758310cd40) at Python/tracemalloc.c:776
#12 0x000055ea736a6c68 in _Py_hashtable_destroy_entry (ht=0x55ea741c0290, entry=0x55ea74335ea0) at Python/hashtable.c:382
#13 0x000055ea736a6cee in _Py_hashtable_clear (ht=0x55ea741c0290) at Python/hashtable.c:398
#14 0x000055ea7370d713 in tracemalloc_clear_traces () at Python/tracemalloc.c:796
#15 0x000055ea7370dbab in _PyTraceMalloc_Stop () at Python/tracemalloc.c:972
#16 0x000055ea73747846 in _tracemalloc_stop_impl (module=<module at remote 0x7f7583b35a90>) at ./Modules/_tracemalloc.c:118
#17 0x000055ea73747726 in _tracemalloc_stop (module=<module at remote 0x7f7583b35a90>, _unused_ignored=0x0) at ./Modules/clinic/_tracemalloc.c.h:132
#18 0x000055ea735386b1 in cfunction_vectorcall_NOARGS (func=<built-in method stop of module object at remote 0x7f7583b35a90>, args=0x7f7584fc2078, nargsf=9223372036854775808, kwnames=0x0) at Objects/methodobject.c:484
#19 0x000055ea734c7cb4 in _PyObject_VectorcallTstate (tstate=0x55ea73cb72d0 <_PyRuntime+508752>, callable=<built-in method stop of module object at remote 0x7f7583b35a90>, args=0x7f7584fc2078, nargsf=9223372036854775808, kwnames=0x0) at ./Include/internal/pycore_call.h:187
@ericsnowcurrently ericsnowcurrently added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump topic-subinterpreters 3.12 only security fixes 3.13 bugs and security fixes labels Sep 28, 2023
@emmatyping
Copy link
Member

Oh! Github search must have failed me when I looked before opening #134604. Should we close this one or the one I opened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-subinterpreters type-crash A hard crash of the interpreter, possibly with a core dump
Projects
Status: Todo
Development

No branches or pull requests

2 participants