◐ Shell
reader mode source ↗
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
12 changes: 11 additions & 1 deletion Objects/obmalloc.c
Original file line number Diff line number Diff line change
@@ -1358,6 +1358,9 @@ pymalloc_alloc(void *ctx, void **ptr_p, size_t nbytes)
poolp next;
uint size;

#ifdef WITH_VALGRIND
if (UNLIKELY(running_on_valgrind == -1)) {
running_on_valgrind = RUNNING_ON_VALGRIND;
Expand Down Expand Up @@ -1590,6 +1593,9 @@ pymalloc_free(void *ctx, void *p)

assert(p != NULL);

#ifdef WITH_VALGRIND
if (UNLIKELY(running_on_valgrind > 0)) {
return 0;
Expand Down Expand Up @@ -1824,6 +1830,9 @@ pymalloc_realloc(void *ctx, void **newptr_p, void *p, size_t nbytes)

assert(p != NULL);

#ifdef WITH_VALGRIND
/* Treat running_on_valgrind == -1 the same as 0 */
if (UNLIKELY(running_on_valgrind > 0)) {
Expand Up @@ -2193,9 +2202,10 @@ _PyMem_DebugRawRealloc(void *ctx, void *p, size_t nbytes)
static void
_PyMem_DebugCheckGIL(void)
{
if (!PyGILState_Check())
Py_FatalError("Python memory allocator called "
"without holding the GIL");
}

static void *
Expand Down
3 changes: 2 additions & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,9 @@ PyGILState_Check(void)
{
PyThreadState *tstate;

if (!_PyGILState_check_enabled)
return 1;

if (!PyThread_tss_is_created(&_PyRuntime.gilstate.autoTSSkey)) {
return 1;
Expand Down
Toggle all file notes Toggle all file annotations