ViennaLS icon indicating copy to clipboard operation
ViennaLS copied to clipboard

Address sanitizer fails in tests

Open tobre1 opened this issue 2 years ago • 3 comments

          Curiously some of the tests (FileWriter, Serialize and VisualizationMesh) failed because the sanitizer found some errors:
Direct leak of 112 byte(s) in 1 object(s) allocated from:
    #0 0x7f886b4e2002 in operator new(unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x7f8863805776 in vtkIdList::New() sources/ViennaLS/build/_deps/vtk-src/Common/Core/vtkIdList.cxx:8
    #2 0x555a45c11f92 in lsWriteVisualizationMesh<float, 3>::removeDuplicatePoints(vtkSmartPointer<vtkPolyData>&, double) sources/ViennaLS/include/lsWriteVisualizationMesh.hpp:92
    #3 0x555a45bf0317 in lsWriteVisualizationMesh<float, 3>::apply() sources/ViennaLS/include/lsWriteVisualizationMesh.hpp:705
    #4 0x555a45be1114 in main sources/ViennaLS/Tests/VisualizationMesh/VisualizationMesh.cpp:75
    #5 0x7f8860645ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f886b4e2182 in operator new[](unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:98
    #1 0x7f8863805d43 in vtkIdList::AllocateInternal(long long, long long) sources/ViennaLS/build/_deps/vtk-src/Common/Core/vtkIdList.cxx:63
    #2 0x7f88638063d8 in vtkIdList::SetNumberOfIds(long long) sources/ViennaLS/build/_deps/vtk-src/Common/Core/vtkIdList.cxx:84
    #3 0x555a45bf1776 in void vtkCellArray_detail::GetCellAtIdImpl::operator()<vtkCellArray::VisitState<vtkTypeInt64Array> >(vtkCellArray::VisitState<vtkTypeInt64Array>&, long long, vtkIdList*) sources/ViennaLS/build/_deps/vtk-src/Common/DataModel/vtkCellArray.h:1447
    #4 0x555a45be6cc1 in void vtkCellArray::Visit<vtkCellArray_detail::GetCellAtIdImpl, long long&, vtkIdList*&, void>(vtkCellArray_detail::GetCellAtIdImpl&&, long long&, vtkIdList*&) sources/ViennaLS/build/_deps/vtk-src/Common/DataModel/vtkCellArray.h:969
    #5 0x555a45be4f26 in vtkCellArray::GetCellAtId(long long, vtkIdList*) sources/ViennaLS/build/_deps/vtk-src/Common/DataModel/vtkCellArray.h:1579
    #6 0x555a45be4de9 in vtkCellArray::GetNextCell(vtkIdList*) sources/ViennaLS/build/_deps/vtk-src/Common/DataModel/vtkCellArray.h:1548
    #7 0x555a45c120dc in lsWriteVisualizationMesh<float, 3>::removeDuplicatePoints(vtkSmartPointer<vtkPolyData>&, double) sources/ViennaLS/include/lsWriteVisualizationMesh.hpp:94
    #8 0x555a45bf0317 in lsWriteVisualizationMesh<float, 3>::apply() sources/ViennaLS/include/lsWriteVisualizationMesh.hpp:705
    #9 0x555a45be1114 in main sources/ViennaLS/Tests/VisualizationMesh/VisualizationMesh.cpp:75
    #10 0x7f8860645ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)

SUMMARY: AddressSanitizer: 144 byte(s) leaked in 2 allocation(s).

We should probably investigate those further

Originally posted by @Curve in https://github.com/ViennaTools/ViennaLS/issues/99#issuecomment-1831745719

tobre1 avatar Nov 29 '23 13:11 tobre1

Memory leak in lsWriteVisualizationMesh (concerning asan fail in ViszaulizationMesh test):

cellPoints on line 92 in lsWriteVisualizationMesh are not initialized as a smart pointer. This can be fixed by changing the line to: auto cellPoints = vtkSmartPointer<vtkIdList>::New();

tobre1 avatar Nov 29 '23 13:11 tobre1

Stack-buffer-overflow in lsDomain and lsPointData (concerning asan fail in FileWriter test):

In the deserialize functions in lsDomain and lsPointData the identifier char array can not safely be converted because the char array does not end in a null char. This can be fixed by increasing the array size by 1 and adding a null termination char at the end.

tobre1 avatar Nov 29 '23 14:11 tobre1

Stack-buffer-underflow in hrleGrid (concerning asan fail Serialize test):

This is an asan fail in the ViennaHRLE library.

tobre1 avatar Nov 29 '23 14:11 tobre1

Should be fixed since version 4.3.0

tobre1 avatar Apr 10 '25 11:04 tobre1