The Wayback Machine - https://web.archive.org/web/20250609032943/https://github.com/python/cpython/issues/113442
Skip to content

memory leak in _PyPathConfig_UpdateGlobal #113442

Open
@nascheme

Description

@nascheme

Bug report

Bug description:

This was found by running ./Programs/_testembed test_repeated_simple_init with valgrind. There should probably be a free operation when the interpreter is freed, in order to free the memory allocated inside _PyPathConfig_UpdateGlobal().

==1291165== 76 bytes in 1 blocks are possibly lost in loss record 3 of 6
==1291165==    at 0x48407B4: malloc (vg_replace_malloc.c:381)
==1291165==    by 0x2FED7B: _PyMem_RawMalloc (obmalloc.c:56)
==1291165==    by 0x302B31: _PyMem_DebugRawAlloc (obmalloc.c:2290)
==1291165==    by 0x302C02: _PyMem_DebugRawMalloc (obmalloc.c:2323)
==1291165==    by 0x3000EA: PyMem_RawMalloc (obmalloc.c:778)
==1291165==    by 0x300326: _PyMem_RawWcsdup (obmalloc.c:867)
==1291165==    by 0x488FBF: _PyPathConfig_UpdateGlobal (pathconfig.c:160)
==1291165==    by 0x4929D1: interpreter_update_config (pylifecycle.c:399)
==1291165==    by 0x494CBA: init_interp_main (pylifecycle.c:1147)
==1291165==    by 0x49563D: pyinit_main (pylifecycle.c:1309)
==1291165==    by 0x4957F4: Py_InitializeFromConfig (pylifecycle.c:1340)
==1291165==    by 0x49590A: Py_InitializeEx (pylifecycle.c:1371)
==1291165==    by 0x495988: Py_Initialize (pylifecycle.c:1381)
==1291165==    by 0x188B72: _testembed_Py_Initialize (_testembed.c:94)
==1291165==    by 0x188DDD: test_repeated_simple_init (_testembed.c:204)
==1291165==    by 0x18D01C: main (_testembed.c:2239)

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions