summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/util.c b/util.c
index c64e88ddc1..b52f00d4b6 100644
--- a/util.c
+++ b/util.c
@@ -4790,7 +4790,11 @@ S_mem_log_common(enum mem_log_type mlt, const UV n,
PERL_ARGS_ASSERT_MEM_LOG_COMMON;
- pmlenv = PerlEnv_getenv("PERL_MEM_LOG");
+ /* Use plain getenv() to avoid potential deadlock with PerlEnv_getenv().
+ * This means that 'pmlenv' is not protected from other threads overwriting
+ * it on platforms where getenv() returns an internal static pointer. See
+ * GH #18341 */
+ pmlenv = getenv("PERL_MEM_LOG");
if (!pmlenv)
return;
if (mlt < MLT_NEW_SV ? strchr(pmlenv,'m') : strchr(pmlenv,'s'))