Skip to content

BUG: LSAN Detected Memory Leaks #54865

Open
@WillAyd

Description

@WillAyd

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

Invoke meson via pip install -ve . --no-build-isolation --config-settings=builddir="asan" --config-settings=setup-args="-Db_sanitize=address"

Also create an LSAN "suppression file" with these contents:

leak:unicode_decode_utf8
leak:PyObject_Malloc

Name that file and provide it via an absolute path to the below command:

LSAN_OPTIONS=suppressions=<absolute_path_to_suppression_file> LD_PRELOAD=$(gcc -print-file-name=libasan.so) python -m pytest pandas/tests/io/json/

Issue Description

You have to sift through a lot, but ASAN detects direct leaks in our codebase from at least the following locations (just running JSON test suite above):

Direct leak of 1440 byte(s) in 36 object(s) allocated from:
    #0 0x7f953ea95749 in __interceptor_calloc ../../../../libsanitizer/asan/asan_malloc_linux.cpp:77
    #1 0x7f94d4f543df in __pyx_pw_6pandas_5_libs_9hashtable_17PyObjectHashTable_1__init__ (/home/willayd/clones/pandas/asan/pandas/_libs/hashtable.cpython-310-x86_64-linux-gnu.so+0x3543df)
    #2 0x55b4f55a1dba in type_call /usr/local/src/conda/python-3.10.12/Objects/typeobject.c:1135

Direct leak of 480 byte(s) in 12 object(s) allocated from:
    #0 0x7f953ea95749 in __interceptor_calloc ../../../../libsanitizer/asan/asan_malloc_linux.cpp:77
    #1 0x7f94d4f301ca in __pyx_tp_new_6pandas_5_libs_9hashtable_Int64HashTable (/home/willayd/clones/pandas/asan/pandas/_libs/hashtable.cpython-310-x86_64-linux-gnu.so+0x3301ca)
    #2 0x55b4f55a1d32 in type_call /usr/local/src/conda/python-3.10.12/Objects/typeobject.c:1123
    #3 0x7f94cc8c3da2 in __pyx_f_6pandas_5_libs_5index_11Int64Engine__make_hash_table (/home/willayd/clones/pandas/asan/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so+0xaada2)
    #4 0x7f94cc9262e3 in __pyx_f_6pandas_5_libs_5index_11IndexEngine__ensure_mapping_populated (/home/willayd/clones/pandas/asan/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so+0x10d2e3)
    #5 0x7f94cc8cbfae in __pyx_f_6pandas_5_libs_5index_11IndexEngine__do_unique_check (/home/willayd/clones/pandas/asan/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so+0xb2fae)
    #6 0x7f94cc8c5973 in __pyx_getprop_6pandas_5_libs_5index_11IndexEngine_is_unique (/home/willayd/clones/pandas/asan/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so+0xac973)
    #7 0x55b4f55a6da9 in _PyObject_GenericGetAttrWithDict /usr/local/src/conda/python-3.10.12/Objects/object.c:1254

Direct leak of 240 byte(s) in 6 object(s) allocated from:
    #0 0x7f953ea95749 in __interceptor_calloc ../../../../libsanitizer/asan/asan_malloc_linux.cpp:77
    #1 0x7f94d4f7b65a in __pyx_tp_new_6pandas_5_libs_9hashtable_UInt64HashTable (/home/willayd/clones/pandas/asan/pandas/_libs/hashtable.cpython-310-x86_64-linux-gnu.so+0x37b65a)
    #2 0x55b4f55a1d32 in type_call /usr/local/src/conda/python-3.10.12/Objects/typeobject.c:1123
    #3 0x7f94cc8a5442 in __pyx_f_6pandas_5_libs_5index_12UInt64Engine__make_hash_table (/home/willayd/clones/pandas/asan/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so+0x8c442)
    #4 0x7f94cc9262e3 in __pyx_f_6pandas_5_libs_5index_11IndexEngine__ensure_mapping_populated (/home/willayd/clones/pandas/asan/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so+0x10d2e3)
    #5 0x7f94cc8cbfae in __pyx_f_6pandas_5_libs_5index_11IndexEngine__do_unique_check (/home/willayd/clones/pandas/asan/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so+0xb2fae)
    #6 0x7f94cc8c5973 in __pyx_getprop_6pandas_5_libs_5index_11IndexEngine_is_unique (/home/willayd/clones/pandas/asan/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so+0xac973)
    #7 0x55b4f55a6da9 in _PyObject_GenericGetAttrWithDict /usr/local/src/conda/python-3.10.12/Objects/object.c:1254

Expected Behavior

No leaks

Installed Versions

INSTALLED VERSIONS

commit : 29873e4
python : 3.10.12.final.0
python-bits : 64
OS : Linux
OS-release : 6.2.0-26-generic
Version : #26-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 10 23:39:54 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.1.0rc0+254.g29873e442c
numpy : 1.22.4
pytz : 2023.3
dateutil : 2.8.2
setuptools : 68.1.2
pip : 23.2.1
Cython : 0.29.33
pytest : 7.4.0
hypothesis : 6.82.7
sphinx : 6.2.1
blosc : None
feather : None
xlsxwriter : 3.1.2
lxml.etree : 4.9.3
html5lib : 1.1
pymysql : 1.4.6
psycopg2 : 2.9.6
jinja2 : 3.1.2
IPython : 8.14.0
pandas_datareader : None
bs4 : 4.12.2
bottleneck : 1.3.7
dataframe-api-compat: None
fastparquet : 2023.7.0
fsspec : 2023.6.0
gcsfs : 2023.6.0
matplotlib : 3.7.2
numba : 0.57.1
numexpr : 2.8.4
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : 1.2.3
pyxlsb : 1.0.10
s3fs : 2023.6.0
scipy : 1.11.2
sqlalchemy : 2.0.20
tables : 3.8.0
tabulate : 0.9.0
xarray : 2023.8.0
xlrd : 2.0.1
zstandard : 0.19.0
tzdata : 2023.3
qtpy : None
pyqt5 : None
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO JSONread_json, to_json, json_normalize

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions