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

Fix tests memory issues with different include #173

Merged
merged 1 commit into from
May 25, 2024
Merged

Fix tests memory issues with different include #173

merged 1 commit into from
May 25, 2024

Conversation

x-mass
Copy link
Contributor

@x-mass x-mass commented May 24, 2024

Currently, if we choose g++ Relase build within Nix environment, tests using <boost/test/included/unit_test.hpp> and BOOST_DATA_TEST_CASE are failing due to heap memory issues (valgrind report is attached below). Technically, tests themselves pass, but process still fails on exit.

Made some expriments. Turned out the issue is gone either if we use <boost/test/unit_test.hpp> instead (header for linked Boost setting) or disable linking flags. In other words, <boost/test/included/unit_test.hpp> and linking to Boost::unit_test_framework are incompatible in this case.

Since in crypto3 we have more <boost/test/unit_test.hpp> usage, I changed tests to use this header.

Valgring Report
make algebra_curves_test && valgrind --leak-check=full --track-origins=yes ./algebra_curves_test 
Building CXX object libs/algebra/test/CMakeFiles/algebra_curves_test.dir/curves.cpp.o
Linking CXX executable algebra_curves_test
Built target algebra_curves_test
==988042== Memcheck, a memory error detector
==988042== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==988042== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==988042== Command: ./algebra_curves_test
==988042== 
Running 296 test cases...

*** No errors detected
==988042== Invalid free() / delete / delete[] / realloc()
==988042==    at 0x48448AF: operator delete(void*) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==988042==    by 0x4CF0A32: __cxa_finalize (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/libc.so.6)
==988042==    by 0x4878AF6: ??? (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x40010E1: _dl_call_fini (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x4004E05: _dl_fini (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x4CF0FA4: __run_exit_handlers (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/libc.so.6)
==988042==    by 0x4CF10DD: exit (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/libc.so.6)
==988042==    by 0x4CD8FD4: (below main) (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/libc.so.6)
==988042==  Address 0x4ebc3c0 is 0 bytes inside a block of size 18 free'd
==988042==    at 0x48448AF: operator delete(void*) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==988042==    by 0x4CF0FA4: __run_exit_handlers (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/libc.so.6)
==988042==    by 0x4CF10DD: exit (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/libc.so.6)
==988042==    by 0x4CD8FD4: (below main) (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/libc.so.6)
==988042==  Block was alloc'd at
==988042==    at 0x4842013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==988042==    by 0x4C6D59: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) [clone .isra.0] (basic_string.tcc:225)
==988042==    by 0x4C34F9: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (unit_test_parameters.ipp:97)
==988042==    by 0x4CD90FD: __libc_start_main@@GLIBC_2.34 (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/libc.so.6)
==988042==    by 0x4C5444: (below main) (in /home/user/crypto3/build/libs/algebra/test/algebra_curves_test)
==988042== 
==988042== 
==988042== HEAP SUMMARY:
==988042==     in use at exit: 102 bytes in 5 blocks
==988042==   total heap usage: 3,056,311 allocs, 3,056,311 frees, 234,329,363 bytes allocated
==988042== 
==988042== 18 bytes in 1 blocks are definitely lost in loss record 1 of 5
==988042==    at 0x4842013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==988042==    by 0x487ABE1: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x487A75D: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> >(char const*, std::allocator<char> const&) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E92D7: __static_initialization_and_destruction_0(int, int) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E9785: _GLOBAL__sub_I_unit_test_parameters.cpp (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x4004FBD: call_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x40050AB: _dl_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x401B07F: ??? (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042== 
==988042== 20 bytes in 1 blocks are definitely lost in loss record 2 of 5
==988042==    at 0x4842013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==988042==    by 0x487ABE1: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x487A75D: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> >(char const*, std::allocator<char> const&) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E8B60: __static_initialization_and_destruction_0(int, int) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E9785: _GLOBAL__sub_I_unit_test_parameters.cpp (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x4004FBD: call_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x40050AB: _dl_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x401B07F: ??? (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042== 
==988042== 20 bytes in 1 blocks are definitely lost in loss record 3 of 5
==988042==    at 0x4842013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==988042==    by 0x487ABE1: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x487A75D: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> >(char const*, std::allocator<char> const&) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E8C71: __static_initialization_and_destruction_0(int, int) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E9785: _GLOBAL__sub_I_unit_test_parameters.cpp (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x4004FBD: call_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x40050AB: _dl_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x401B07F: ??? (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042== 
==988042== 21 bytes in 1 blocks are definitely lost in loss record 4 of 5
==988042==    at 0x4842013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==988042==    by 0x487ABE1: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x487A75D: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> >(char const*, std::allocator<char> const&) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E8C16: __static_initialization_and_destruction_0(int, int) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E9785: _GLOBAL__sub_I_unit_test_parameters.cpp (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x4004FBD: call_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x40050AB: _dl_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x401B07F: ??? (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042== 
==988042== 23 bytes in 1 blocks are definitely lost in loss record 5 of 5
==988042==    at 0x4842013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==988042==    by 0x487ABE1: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x487A75D: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> >(char const*, std::allocator<char> const&) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E905A: __static_initialization_and_destruction_0(int, int) (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x48E9785: _GLOBAL__sub_I_unit_test_parameters.cpp (in /nix/store/0m2ddvr1l4az5l3h0b50l1pll91yqyv8-boost-1.83.0/lib/libboost_unit_test_framework-mt-d-x64.so.1.83.0)
==988042==    by 0x4004FBD: call_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x40050AB: _dl_init (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042==    by 0x401B07F: ??? (in /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2)
==988042== 
==988042== LEAK SUMMARY:
==988042==    definitely lost: 102 bytes in 5 blocks
==988042==    indirectly lost: 0 bytes in 0 blocks
==988042==      possibly lost: 0 bytes in 0 blocks
==988042==    still reachable: 0 bytes in 0 blocks
==988042==         suppressed: 0 bytes in 0 blocks
==988042== 
==988042== For lists of detected and suppressed errors, rerun with: -s
==988042== ERROR SUMMARY: 10 errors from 6 contexts (suppressed: 0 from 0)

@x-mass x-mass requested review from martun and vo-nil May 24, 2024 09:02
Copy link

github-actions bot commented May 24, 2024

Linux Test Results

1 558 tests  ±0   1 558 ✅ ±0   5m 37s ⏱️ -1s
    6 suites ±0       0 💤 ±0 
    6 files   ±0       0 ❌ ±0 

Results for commit c4db9c8. ± Comparison against base commit a3d40d8.

♻️ This comment has been updated with latest results.

@x-mass x-mass merged commit f4a68ed into master May 25, 2024
3 checks passed
@x-mass x-mass deleted the fix-heap branch May 25, 2024 10:39
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.

2 participants