Skip to content
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

memory leak in _PyPathConfig_UpdateGlobal #113442

Open
nascheme opened this issue Dec 23, 2023 · 2 comments
Open

memory leak in _PyPathConfig_UpdateGlobal #113442

nascheme opened this issue Dec 23, 2023 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@nascheme
Copy link
Member

nascheme commented Dec 23, 2023

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

@nascheme nascheme added the type-bug An unexpected behavior, bug, or error label Dec 23, 2023
@nascheme
Copy link
Member Author

Found while investigating gh-113055. This leak seems to be the last remaining one for the test if the global interned string cache is disabled.

@neonene
Copy link
Contributor

neonene commented Dec 24, 2023

IIUC, 3.11 behaves like that, where _PyPathConfig_UpdateGlobal() has the PyMem_RawFree functions. As to 3.11, I cannot see the measurable memory leak with the 5000 times of init/fini cycles followed by _PyPathConfig_UpdateGlobal().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants