Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address sanitizer fails in tests #100

Open
tobre1 opened this issue Nov 29, 2023 · 3 comments
Open

Address sanitizer fails in tests #100

tobre1 opened this issue Nov 29, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@tobre1
Copy link
Member

tobre1 commented Nov 29, 2023

          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 #99 (comment)

@tobre1 tobre1 added the bug Something isn't working label Nov 29, 2023
@tobre1
Copy link
Member Author

tobre1 commented Nov 29, 2023

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
Copy link
Member Author

tobre1 commented Nov 29, 2023

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
Copy link
Member Author

tobre1 commented Nov 29, 2023

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

This is an asan fail in the ViennaHRLE library.

@tobre1 tobre1 changed the title Memory leak in tests Address sanitizer fails in tests Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant