Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *op, Py_ssize_t extra);
extern int _PyType_CheckConsistency(PyTypeObject *type);
extern int _PyDict_CheckConsistency(PyObject *mp, int check_content);

/* Update the Python traceback of an object. This function must be called
when a memory block is reused from a free list.

Internal function called by _Py_NewReference(). */
extern int _PyTraceMalloc_TraceRef(PyObject *op, PyRefTracerEvent event, void*);

// Fast inlined version of PyType_HasFeature()
static inline int
_PyType_HasFeature(PyTypeObject *type, unsigned long feature) {
Expand Down
10 changes: 5 additions & 5 deletions Include/internal/pycore_tracemalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct _PyTraceMalloc_Config {
} initialized;

/* Is tracemalloc tracing memory allocations?
Variable protected by the GIL */
Variable protected by the TABLES_LOCK(). */
int tracing;

/* limit of the number of frames in a traceback, 1 by default.
Expand Down Expand Up @@ -85,14 +85,14 @@ struct _tracemalloc_runtime_state {
size_t peak_traced_memory;
/* Hash table used as a set to intern filenames:
PyObject* => PyObject*.
Protected by the GIL */
Protected by the TABLES_LOCK(). */
_Py_hashtable_t *filenames;
/* Buffer to store a new traceback in traceback_new().
Protected by the GIL. */
Protected by the TABLES_LOCK(). */
struct tracemalloc_traceback *traceback;
/* Hash table used as a set to intern tracebacks:
traceback_t* => traceback_t*
Protected by the GIL */
Protected by the TABLES_LOCK(). */
_Py_hashtable_t *tracebacks;
/* pointer (void*) => trace (trace_t*).
Protected by TABLES_LOCK(). */
Expand Down Expand Up @@ -144,7 +144,7 @@ extern PyObject* _PyTraceMalloc_GetTraces(void);
extern PyObject* _PyTraceMalloc_GetObjectTraceback(PyObject *obj);

/* Initialize tracemalloc */
extern int _PyTraceMalloc_Init(void);
extern PyStatus _PyTraceMalloc_Init(void);

/* Start tracemalloc */
extern int _PyTraceMalloc_Start(int max_nframe);
Expand Down
16 changes: 6 additions & 10 deletions Modules/_tracemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,14 @@ static struct PyModuleDef module_def = {
PyMODINIT_FUNC
PyInit__tracemalloc(void)
{
PyObject *m;
m = PyModule_Create(&module_def);
if (m == NULL)
PyObject *mod = PyModule_Create(&module_def);
if (mod == NULL) {
return NULL;
}

#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
#endif

if (_PyTraceMalloc_Init() < 0) {
Py_DECREF(m);
return NULL;
}

return m;
return mod;
}
7 changes: 6 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,12 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
// the settings are loaded (so that feature_flags are set) but before
// any calls are made to obmalloc functions.
if (_PyMem_init_obmalloc(interp) < 0) {
return _PyStatus_NO_MEMORY();
return _PyStatus_NO_MEMORY();
}

status = _PyTraceMalloc_Init();
if (_PyStatus_EXCEPTION(status)) {
return status;
}

PyThreadState *tstate = _PyThreadState_New(interp,
Expand Down
Loading
Loading