[c++] Fix heap corruption in fastercsx
#3365
Merged
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue and/or context: Found while debugging (details below).
Issue: #3345; see also #3304.
Changes:
We have a pair of macros
tdb_new_array
andtdb_delete_array
. As written, these are pairingmalloc
withdelete []
. This is incorrect behavior, which this PR fixes.Also note that this defect is new to our modified vendoring of
threadpool/status.h
:TileDB-SOMA/libtiledbsoma/src/external/include/thread_pool/status.h
Lines 60 to 64 in ca00d5b
Given the narrative at #3304 (comment) I did not review these files on my review of #3304; I'll take another look now including a diff against the core vendoring-source files.
Also note that
libtiledbsoma/src/external/include/thread_pool/status.h
is not new to #3304, but newly exercised by #3304.Notes for Reviewer:
I found this while debugging an issue: on my laptop (but not in CI) there is a segfault here:
TileDB-SOMA/apis/python/tests/test_fastercsx.py
Lines 352 to 363 in ca00d5b
This intends to catch an exception thrown through this callchain, as revealed by source-level debugging this morning:
TileDB-SOMA/apis/python/src/tiledbsoma/_fastercsx.py
Lines 86 to 88 in ca00d5b
TileDB-SOMA/libtiledbsoma/src/utils/fastercsx.h
Lines 310 to 320 in ca00d5b
TileDB-SOMA/libtiledbsoma/src/utils/fastercsx.h
Lines 389 to 398 in ca00d5b
TileDB-SOMA/libtiledbsoma/src/utils/fastercsx.h
Line 286 in ca00d5b
Here is a standalone repro which crashes for me, taken from
apis/python/tests/test_fastercsx.py::test_bad_shapes
:This does crash for me on my laptop; I does not crash for me on an Ubuntu system, and our multi-platform CI is green on
main
. Nonetheless I ranvalgrind
on an Ubuntu system, to investigate. I found the following:The
valgrind
outputled me directly to the codemod addressed on this PR.
Do note however that even after a clean and rebuild I do still experience the segfault with the above scenario on my laptop. This means that I've found a heap-corruption issue on this PR, but there appears to be something else going on as well.