This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ASAN : Memory leak in compilation
Type: resource usage Stage: resolved
Components: Build Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Ramin Farajpour Cami, christian.heimes, lys.nikolaou, pablogsal
Priority: normal Keywords:

Created on 2021-02-23 05:57 by Ramin Farajpour Cami, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg387551 - (view) Author: Ramin Farajpour Cami (Ramin Farajpour Cami) Date: 2021-02-23 05:57
Hi,


Asan has detected a memory leak :

$ wget https://github.com/python/cpython/archive/v3.9.2.tar.gz
$ tar xvf v3.9.2.tar.gz
$ ./configure --disable-shared CFLAGS="-fsanitize=address -ggdb" CXXFLAGS="-fsanitize=address -ggdb" LDFLAGS="-fsanitize=address"
$ make -j4
$ ~/cpython-3.9.2# ./python -E -S -m sysconfig --generate-posix-vars

=================================================================
==330505==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 300082 byte(s) in 137 object(s) allocated from:
    #0 0x7f647a692bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55a58e972015 in PyMem_RawMalloc Objects/obmalloc.c:572
    #2 0x55a58e972015 in _PyObject_Malloc Objects/obmalloc.c:1645
    #3 0x55a58e972015 in _PyObject_Malloc Objects/obmalloc.c:1638

Direct leak of 2066 byte(s) in 2 object(s) allocated from:
    #0 0x7f647a692ffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
    #1 0x55a58e9c9e7d in resize_compact Objects/unicodeobject.c:1079

Direct leak of 672 byte(s) in 1 object(s) allocated from:
    #0 0x7f647a692ffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
    #1 0x55a58eb6c620 in _PyObject_GC_Resize Modules/gcmodule.c:2297

Indirect leak of 110001 byte(s) in 115 object(s) allocated from:
    #0 0x7f647a692bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55a58e972015 in PyMem_RawMalloc Objects/obmalloc.c:572
    #2 0x55a58e972015 in _PyObject_Malloc Objects/obmalloc.c:1645
    #3 0x55a58e972015 in _PyObject_Malloc Objects/obmalloc.c:1638

Indirect leak of 536 byte(s) in 1 object(s) allocated from:
    #0 0x7f647a692bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55a58e972382 in _PyObject_Malloc Objects/obmalloc.c:572
    #2 0x55a58e972382 in pymalloc_realloc Objects/obmalloc.c:1988
    #3 0x55a58e972382 in _PyObject_Realloc Objects/obmalloc.c:2007

SUMMARY: AddressSanitizer: 413357 byte(s) leaked in 256 allocation(s).


Thanks,
Ramin
msg387555 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-23 08:41
To run the address sanitizer you need to deactivate pymalloc and pass some of the asan flags to avoid false positives. Check our our buildbot configuration for it:

https://github.com/python/buildmaster-config/blob/master/master/custom/factories.py#L223

This looks like a false positive to me.
History
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87469
2021-02-25 07:42:08Ramin Farajpour Camisetstatus: open -> closed
stage: resolved
2021-02-23 08:41:06pablogsalsetmessages: + msg387555
2021-02-23 06:48:39Ramin Farajpour Camisetnosy: + christian.heimes, lys.nikolaou, pablogsal
2021-02-23 05:57:00Ramin Farajpour Camicreate