-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
When building Python with address sanitizer ./configure --with-pydebug --with-address-sanitizer CFLAGS="-O0"
, the build fails with the following error:
==768783==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 68 byte(s) in 1 object(s) allocated from:
#0 0x7fd85a0e6f2b in malloc (/lib64/libasan.so.8+0xe6f2b) (BuildId: 10b8ccd49f75c21babf1d7abe51bb63589d8471f)
#1 0x000000a8a258 in utf8_to_wstr Python/initconfig.c:4054
#2 0x000000a8a643 in PyInitConfig_SetStr Python/initconfig.c:4088
#3 0x00000040238d in runtime_init Programs/_freeze_module.c:57
#4 0x0000004030ee in main Programs/_freeze_module.c:237
#5 0x7fd859e11574 in __libc_start_call_main (/lib64/libc.so.6+0x3574) (BuildId: 48c4b9b1efb1df15da8e787f489128bf31893317)
#6 0x7fd859e11627 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x3627) (BuildId: 48c4b9b1efb1df15da8e787f489128bf31893317)
#7 0x000000401eb4 in _start (/home/vstinner/python/main/Programs/_freeze_module+0x401eb4) (BuildId: 871b1eb54b816428317fe79f8100da96490cf4fc)
SUMMARY: AddressSanitizer: 68 byte(s) leaked in 1 allocation(s).
make: *** [Makefile:1937: Python/frozen_modules/importlib._bootstrap_external.h] Error 1
The problem is that the PyInitConfig C API leaks memory. PyInitConfig_Free() doesn't release memory allocated by PyInitConfig_SetStr().
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error