Skip to content

[c++/python] Fix domain getter memory leak on C++/Python layer#4066

Merged
jp-dark merged 11 commits intomainfrom
xanthosxanthopoulos/soma-169-c-memory-leak-in-somaarray_get_core_domainish
May 21, 2025
Merged

[c++/python] Fix domain getter memory leak on C++/Python layer#4066
jp-dark merged 11 commits intomainfrom
xanthosxanthopoulos/soma-169-c-memory-leak-in-somaarray_get_core_domainish

Conversation

@XanthosXanthopoulos
Copy link
Copy Markdown
Collaborator

Issue and/or context: SOMA-169

Changes:

Notes for Reviewer:

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2025

Codecov Report

Attention: Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.

Project coverage is 66.01%. Comparing base (f29839d) to head (b38fc54).
Report is 7 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4066       +/-   ##
===========================================
- Coverage   88.97%   66.01%   -22.96%     
===========================================
  Files          59      158       +99     
  Lines        7073    21049    +13976     
  Branches        0     1236     +1236     
===========================================
+ Hits         6293    13895     +7602     
- Misses        780     6742     +5962     
- Partials        0      412      +412     
Flag Coverage Δ
libtiledbsoma 54.25% <0.00%> (?)
python 89.26% <ø> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
python_api 89.26% <ø> (+0.29%) ⬆️
libtiledbsoma 44.66% <0.00%> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bkmartinjr
Copy link
Copy Markdown
Member

I built this branch and ran under valgrind. Am still seeing quite a few leaks in this call chain (i.e., _get_core_domainish)

My test case:

valgrind --max-threads=4096 --leak-check=full pytest -s -x -v apis/python/tests/test_shape.py

Leaks:

==361621== 12 bytes in 4 blocks are definitely lost in loss record 1,151 of 7,631
==361621==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==361621==    by 0x4A0E58E: strdup (strdup.c:42)
==361621==    by 0x873DDB4D: tiledbsoma::ArrowAdapter::make_arrow_schema_parent(unsigned long, std::basic_string_view<char, std::char_traits<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x8731B0C0: tiledbsoma::SOMAArray::_get_core_domainish(Domainish) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x8732A218: tiledbsoma::SOMAArray::_set_soma_joinid_shape_helper(long, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x87009C08: pybind11::cpp_function::initialize<libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}, void, tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, pybind11::arg>(libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}&&, void (*)(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, pybind11::arg const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==361621==    by 0x86D05613: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==361621==    by 0x323D37: cfunction_call (methodobject.c:537)
==361621==    by 0x30726B: _PyObject_MakeTpCall (call.c:240)
==361621==    by 0x21AB4E: _PyEval_EvalFrameDefault.cold (bytecodes.c:2715)
==361621==    by 0x309CF1: _PyObject_FastCallDictTstate (call.c:144)
==361621==    by 0x3327A8: _PyObject_Call_Prepend (call.c:508)

==361621== 28 bytes in 4 blocks are definitely lost in loss record 1,941 of 7,631
==361621==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==361621==    by 0x4A0E58E: strdup (strdup.c:42)
==361621==    by 0x873DDB5C: tiledbsoma::ArrowAdapter::make_arrow_schema_parent(unsigned long, std::basic_string_view<char, std::char_traits<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x8731B0C0: tiledbsoma::SOMAArray::_get_core_domainish(Domainish) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x8732A218: tiledbsoma::SOMAArray::_set_soma_joinid_shape_helper(long, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x87009C08: pybind11::cpp_function::initialize<libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}, void, tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, pybind11::arg>(libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}&&, void (*)(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, pybind11::arg const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==361621==    by 0x86D05613: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==361621==    by 0x323D37: cfunction_call (methodobject.c:537)
==361621==    by 0x30726B: _PyObject_MakeTpCall (call.c:240)
==361621==    by 0x21AB4E: _PyEval_EvalFrameDefault.cold (bytecodes.c:2715)
==361621==    by 0x309CF1: _PyObject_FastCallDictTstate (call.c:144)
==361621==    by 0x3327A8: _PyObject_Call_Prepend (call.c:508)

==361621== 555 (48 direct, 507 indirect) bytes in 4 blocks are definitely lost in loss record 6,649 of 7,631
==361621==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==361621==    by 0x873DDB85: tiledbsoma::ArrowAdapter::make_arrow_schema_parent(unsigned long, std::basic_string_view<char, std::char_traits<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x8731B0C0: tiledbsoma::SOMAArray::_get_core_domainish(Domainish) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x8732A218: tiledbsoma::SOMAArray::_set_soma_joinid_shape_helper(long, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x87009C08: pybind11::cpp_function::initialize<libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}, void, tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, pybind11::arg>(libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}&&, void (*)(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, pybind11::arg const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==361621==    by 0x86D05613: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==361621==    by 0x323D37: cfunction_call (methodobject.c:537)
==361621==    by 0x30726B: _PyObject_MakeTpCall (call.c:240)
==361621==    by 0x21AB4E: _PyEval_EvalFrameDefault.cold (bytecodes.c:2715)
==361621==    by 0x309CF1: _PyObject_FastCallDictTstate (call.c:144)
==361621==    by 0x3327A8: _PyObject_Call_Prepend (call.c:508)
==361621==    by 0x3FF2FA: slot_tp_call (typeobject.c:8791)

==361621== 728 (48 direct, 680 indirect) bytes in 4 blocks are definitely lost in loss record 6,751 of 7,631
==361621==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==361621==    by 0x873DE03A: tiledbsoma::ArrowAdapter::make_arrow_array_parent(unsigned long) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x8731B0CD: tiledbsoma::SOMAArray::_get_core_domainish(Domainish) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x8732A218: tiledbsoma::SOMAArray::_set_soma_joinid_shape_helper(long, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==361621==    by 0x87009C08: pybind11::cpp_function::initialize<libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}, void, tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, pybind11::arg>(libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}&&, void (*)(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, pybind11::arg const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==361621==    by 0x86D05613: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==361621==    by 0x323D37: cfunction_call (methodobject.c:537)
==361621==    by 0x30726B: _PyObject_MakeTpCall (call.c:240)
==361621==    by 0x21AB4E: _PyEval_EvalFrameDefault.cold (bytecodes.c:2715)
==361621==    by 0x309CF1: _PyObject_FastCallDictTstate (call.c:144)
==361621==    by 0x3327A8: _PyObject_Call_Prepend (call.c:508)
==361621==    by 0x3FF2FA: slot_tp_call (typeobject.c:8791)

Copy link
Copy Markdown
Member

@bkmartinjr bkmartinjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of items:

  • is this still WIP? (PR title)
  • I built the branch and ran valgrind - still see multiple leaks in this call chain. Left details in a comment

If you were intending to do a PR for each specific leak, LMK and I can re-review. No concerns with the actual changes in this PR.

@johnkerl
Copy link
Copy Markdown
Contributor

@XanthosXanthopoulos #4067 may help?

@johnkerl johnkerl changed the title [c++/python] Fix domain getter memory leak on C++/Python layer [WIP] [c++/python] Fix domain getter memory leak on C++/Python layer May 19, 2025
@johnkerl johnkerl changed the title [c++/python] Fix domain getter memory leak on C++/Python layer [c++/python] Fix domain getter memory leak on C++/Python layer [WIP] May 19, 2025
@XanthosXanthopoulos XanthosXanthopoulos marked this pull request as draft May 20, 2025 10:04
@bkmartinjr
Copy link
Copy Markdown
Member

Update after latest commit. Ran:

valgrind --max-threads=4096 --leak-check=full pytest -s -x -v apis/python/tests/test_shape.py -k test_canned_experiments[False]

And leaked:

==2066522== 4 bytes in 2 blocks are definitely lost in loss record 241 of 7,551
==2066522==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2066522==    by 0x4A0E58E: strdup (strdup.c:42)
==2066522==    by 0x873E0309: tiledbsoma::ArrowAdapter::arrow_schema_from_tiledb_attribute(tiledb::Attribute const&, tiledb::Context const&, tiledb::Array const&) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==2066522==    by 0x873579A2: tiledbsoma::SOMAAttribute::arrow_schema_slot(tiledbsoma::SOMAContext const&, tiledb::Array&) const (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==2066522==    by 0x86FB7348: libtiledbsomacpp::load_soma_array(pybind11::module_&)::{lambda(tiledbsoma::SOMAArray&)#7}::operator()(tiledbsoma::SOMAArray&) const [clone .constprop.0] (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==2066522==    by 0x86FB8452: pybind11::cpp_function::initialize<libtiledbsomacpp::load_soma_array(pybind11::module_&)::{lambda(tiledbsoma::SOMAArray&)#7} const&, pybind11::object, tiledbsoma::SOMAArray&>(libtiledbsomacpp::load_soma_array(pybind11::module_&)::{lambda(tiledbsoma::SOMAArray&)#7} const&, pybind11::object (*)(tiledbsoma::SOMAArray&))::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==2066522==    by 0x86D055C3: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==2066522==    by 0x323D37: cfunction_call (methodobject.c:537)
==2066522==    by 0x30726B: _PyObject_MakeTpCall (call.c:240)
==2066522==    by 0x330577: UnknownInlinedFun (pycore_call.h:90)
==2066522==    by 0x330577: UnknownInlinedFun (pycore_call.h:77)
==2066522==    by 0x330577: PyObject_CallOneArg (call.c:401)
==2066522==    by 0x322A55: _PyObject_GenericGetAttrWithDict (object.c:1447)
==2066522==    by 0x309720: UnknownInlinedFun (object.c:1538)


==2066522== 9 bytes in 3 blocks are definitely lost in loss record 742 of 7,551
==2066522==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2066522==    by 0x4A0E58E: strdup (strdup.c:42)
==2066522==    by 0x873DDB4D: tiledbsoma::ArrowAdapter::make_arrow_schema_parent(unsigned long, std::basic_string_view<char, std::char_traits<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==2066522==    by 0x8731B0C0: tiledbsoma::SOMAArray::_get_core_domainish(Domainish) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==2066522==    by 0x8732A218: tiledbsoma::SOMAArray::_set_soma_joinid_shape_helper(long, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==2066522==    by 0x87009678: pybind11::cpp_function::initialize<libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}, void, tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, pybind11::arg>(libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}&&, void (*)(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, pybind11::arg const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==2066522==    by 0x86D055C3: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==2066522==    by 0x323D37: cfunction_call (methodobject.c:537)
==2066522==    by 0x30726B: _PyObject_MakeTpCall (call.c:240)
==2066522==    by 0x21AB4E: _PyEval_EvalFrameDefault.cold (bytecodes.c:2715)
==2066522==    by 0x309CF1: _PyObject_FastCallDictTstate (call.c:144)
==2066522==    by 0x3327A8: _PyObject_Call_Prepend (call.c:508)

==2066522== 21 bytes in 3 blocks are definitely lost in loss record 1,380 of 7,551
==2066522==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2066522==    by 0x4A0E58E: strdup (strdup.c:42)
==2066522==    by 0x873DDB5C: tiledbsoma::ArrowAdapter::make_arrow_schema_parent(unsigned long, std::basic_string_view<char, std::char_traits<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==2066522==    by 0x8731B0C0: tiledbsoma::SOMAArray::_get_core_domainish(Domainish) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==2066522==    by 0x8732A218: tiledbsoma::SOMAArray::_set_soma_joinid_shape_helper(long, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/bruce/projects/TileDB-SOMA/dist/lib/libtiledbsoma.so)
==2066522==    by 0x87009678: pybind11::cpp_function::initialize<libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}, void, tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, pybind11::arg>(libtiledbsomacpp::load_soma_dataframe(pybind11::module_&)::{lambda(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#6}&&, void (*)(tiledbsoma::SOMADataFrame&, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, pybind11::arg const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==2066522==    by 0x86D055C3: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (in /home/bruce/projects/TileDB-SOMA/apis/python/src/tiledbsoma/pytiledbsoma.cpython-312-x86_64-linux-gnu.so)
==2066522==    by 0x323D37: cfunction_call (methodobject.c:537)
==2066522==    by 0x30726B: _PyObject_MakeTpCall (call.c:240)
==2066522==    by 0x21AB4E: _PyEval_EvalFrameDefault.cold (bytecodes.c:2715)
==2066522==    by 0x309CF1: _PyObject_FastCallDictTstate (call.c:144)
==2066522==    by 0x3327A8: _PyObject_Call_Prepend (call.c:508)

@johnkerl
Copy link
Copy Markdown
Contributor

And leaked:

This is because of
https://github.com/single-cell-data/TileDB-SOMA/blob/xanthosxanthopoulos/soma-169-c-memory-leak-in-somaarray_get_core_domainish/libtiledbsoma/src/utils/arrow_adapter.cc#L539-L546

  • dict->format is strdup'ed outside the if
  • then again inside the if

@johnkerl
Copy link
Copy Markdown
Contributor

johnkerl commented May 20, 2025

With this mod compiled in my sandbox I re-ran

valgrind --error-limit=no --trace-children=yes -s --leak-check=full $(which python) ~/130.py

as detailed on #4065 and #4067, and I no longer see the strdup leak appearing in the output from valgrind

Comment thread apis/python/src/tiledbsoma/soma_array.cc Outdated
Comment thread apis/python/src/tiledbsoma/soma_array.cc Outdated
@XanthosXanthopoulos XanthosXanthopoulos changed the title [c++/python] Fix domain getter memory leak on C++/Python layer [WIP] [c++/python] Fix domain getter memory leak on C++/Python layer May 21, 2025
@XanthosXanthopoulos XanthosXanthopoulos marked this pull request as ready for review May 21, 2025 14:59
@bkmartinjr
Copy link
Copy Markdown
Member

I ran a couple of quick unit tests for validation, and for those I tested, things are clean.

Copy link
Copy Markdown
Member

@bkmartinjr bkmartinjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am doing final testing in parallel, but LGTM

@jp-dark jp-dark merged commit f1b0ac5 into main May 21, 2025
25 of 26 checks passed
@jp-dark jp-dark deleted the xanthosxanthopoulos/soma-169-c-memory-leak-in-somaarray_get_core_domainish branch May 21, 2025 18:58
github-actions Bot pushed a commit that referenced this pull request May 21, 2025
* Fix memory

* Release exported arrays

* fix double strdup which was leaking 2 bytes per enumerated column

* More missing arrow releases

* Use scoped executor for arrow cleanup

* Release schema in `_set_soma_joinid_shape_helper`

* Apply suggestions from code review

Co-authored-by: John Kerl <[email protected]>

* Release memory for outline transformer

* lint fixes

* Update changelog

* Disable mdformat - CI failures not reproducing locally

---------

Co-authored-by: John Kerl <[email protected]>
jp-dark pushed a commit that referenced this pull request May 21, 2025
#4078)

* Fix memory

* Release exported arrays

* fix double strdup which was leaking 2 bytes per enumerated column

* More missing arrow releases

* Use scoped executor for arrow cleanup

* Release schema in `_set_soma_joinid_shape_helper`

* Apply suggestions from code review



* Release memory for outline transformer

* lint fixes

* Update changelog

* Disable mdformat - CI failures not reproducing locally

---------

Co-authored-by: XanthosXanthopoulos <[email protected]>
Co-authored-by: John Kerl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants