Assertion failure in test-matrixwrapper on master
Created by: twesterhout
In search of the memory leak in #29 I've tried running tests on master with NETKET_Sanitizer=ON
. test-matrixwrapper_default
and test-matrixwrapper_all
both trigger an assertion failure for BoseHubbard
. I think it might be a good idea to fix this first before proceeding further with #29.
# Hypercube created
# Dimension = 2
# L = 2
# Pbc = 0
# Bose Hubbard model created
test-matrixwrapper: /home/tom/src/netket/NetKet/Hilbert/bosons.hpp:158: virtual void netket::Boson::UpdateConf(Eigen::VectorXd &, const std::vector<int> &, const std::vector<double> &) const: Assertion `CheckConstraint(v)' failed.
=================================================================
==27721==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000200cf40 at pc 0x0000009b2490 bp 0x00000200cef0 sp 0x00000200cee8
WRITE of size 8 at 0x00000200cf40 thread T0
#0 0x9b248f in unsigned long* std::__uninitialized_copy<true>::__uninit_copy<std::move_iterator<unsigned long*>, unsigned long*>(std::move_iterator<unsigned long*>, std::move_iterator<unsigned long*>, unsigned long*) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_uninitialized.h
#1 0x9b2293 in unsigned long* std::uninitialized_copy<std::move_iterator<unsigned long*>, unsigned long*>(std::move_iterator<unsigned long*>, std::move_iterator<unsigned long*>, unsigned long*) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_uninitialized.h:131:14
#2 0x9b1e69 in unsigned long* std::__uninitialized_copy_a<std::move_iterator<unsigned long*>, unsigned long*, unsigned long>(std::move_iterator<unsigned long*>, std::move_iterator<unsigned long*>, unsigned long*, std::allocator<unsigned long>&) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_uninitialized.h:289:14
#3 0x9b13c8 in unsigned long* std::__uninitialized_move_if_noexcept_a<unsigned long*, unsigned long*, std::allocator<unsigned long> >(unsigned long*, unsigned long*, unsigned long*, std::allocator<unsigned long>&) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_uninitialized.h:310:14
#4 0x9afcd3 in void std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long const&>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long const&&&) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/vector.tcc:446:8
#5 0x9aee3d in std::vector<unsigned long, std::allocator<unsigned long> >::push_back(unsigned long const&) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_vector.h:1085:4
#6 0xc845a0 in Catch::StringStreams::release(unsigned long) /home/tom/src/netket/External/Catch/catch.hpp:9515:22
#7 0xbd022b in Catch::ReusableStringStream::~ReusableStringStream() /home/tom/src/netket/External/Catch/catch.hpp:9544:35
#8 0xc78401 in Catch::MessageStream::~MessageStream() /home/tom/src/netket/External/Catch/catch.hpp:1608:12
#9 0xc70eb4 in Catch::MessageBuilder::~MessageBuilder() /home/tom/src/netket/External/Catch/catch.hpp:1619:12
#10 0xb95993 in Catch::AssertionStats::AssertionStats(Catch::AssertionResult const&, std::vector<Catch::MessageInfo, std::allocator<Catch::MessageInfo> > const&, Catch::Totals const&) /home/tom/src/netket/External/Catch/catch.hpp:7566:9
#11 0xbb7a76 in Catch::RunContext::assertionEnded(Catch::AssertionResult const&) /home/tom/src/netket/External/Catch/catch.hpp:8642:54
#12 0xbbcd02 in Catch::RunContext::handleFatalErrorCondition(Catch::StringRef) /home/tom/src/netket/External/Catch/catch.hpp:8741:9
#13 0xb93893 in (anonymous namespace)::reportFatal(char const*) /home/tom/src/netket/External/Catch/catch.hpp:7313:56
#14 0xb9328d in Catch::FatalConditionHandler::handleSignal(int) /home/tom/src/netket/External/Catch/catch.hpp:7402:9
#15 0x7f0c45642f4f (/lib/x86_64-linux-gnu/libpthread.so.0+0x11f4f)
#16 0x7f0c44c87e7a in gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x34e7a)
#17 0x7f0c44c89230 in abort (/lib/x86_64-linux-gnu/libc.so.6+0x36230)
#18 0x7f0c44c809d9 (/lib/x86_64-linux-gnu/libc.so.6+0x2d9d9)
#19 0x7f0c44c80a51 in __assert_fail (/lib/x86_64-linux-gnu/libc.so.6+0x2da51)
#20 0x92009a in netket::Boson::UpdateConf(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, std::vector<int, std::allocator<int> > const&, std::vector<double, std::allocator<double> > const&) const /home/tom/src/netket/NetKet/Hilbert/bosons.hpp:158:7
#21 0x8ee8b9 in netket::Hilbert::UpdateConf(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, std::vector<int, std::allocator<int> > const&, std::vector<double, std::allocator<double> > const&) const /home/tom/src/netket/NetKet/Hilbert/hilbert.hpp:104:16
#22 0x9a86f0 in netket::SparseMatrixWrapper<netket::AbstractHamiltonian, Eigen::Matrix<std::complex<double>, -1, 1, 0, -1, 1> >::InitializeMatrix(netket::AbstractHamiltonian const&) /home/tom/src/netket/NetKet/Hamiltonian/MatrixWrapper/sparse_matrix_wrapper.hpp:91:25
#23 0x861470 in netket::SparseMatrixWrapper<netket::AbstractHamiltonian, Eigen::Matrix<std::complex<double>, -1, 1, 0, -1, 1> >::SparseMatrixWrapper(netket::AbstractHamiltonian const&) /home/tom/src/netket/NetKet/Hamiltonian/MatrixWrapper/sparse_matrix_wrapper.hpp:41:9
#24 0x849068 in ____C_A_T_C_H____T_E_S_T____0() /home/tom/src/netket/Test/Hamiltonian/unit-matrixwrapper.cc:85:70
#25 0xbdc059 in Catch::TestInvokerAsFunction::invoke() const /home/tom/src/netket/External/Catch/catch.hpp:10067:9
#26 0xbbf453 in Catch::TestCase::invoke() const /home/tom/src/netket/External/Catch/catch.hpp:9968:15
#27 0xbbf104 in Catch::RunContext::invokeActiveTestCase() /home/tom/src/netket/External/Catch/catch.hpp:8832:27
#28 0xbb5511 in Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) /home/tom/src/netket/External/Catch/catch.hpp:8806:17
#29 0xbb122d in Catch::RunContext::runTest(Catch::TestCase const&) /home/tom/src/netket/External/Catch/catch.hpp:8595:13
#30 0xbcd235 in Catch::(anonymous namespace)::runTests(std::shared_ptr<Catch::Config> const&) /home/tom/src/netket/External/Catch/catch.hpp:9135:39
#31 0xbca54c in Catch::Session::runInternal() /home/tom/src/netket/External/Catch/catch.hpp:9333:27
#32 0xbc93a6 in Catch::Session::run() /home/tom/src/netket/External/Catch/catch.hpp:9290:24
#33 0xbc9047 in Catch::Session::run(int, char**) /home/tom/src/netket/External/Catch/catch.hpp:9258:26
#34 0xc2a9eb in main /home/tom/src/netket/Test/unit-tests.cc:9:33
#35 0x7f0c44c74a86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21a86)
#36 0x725729 in _start (/home/tom/src/netket/build/Test/test-matrixwrapper+0x725729)
0x00000200cf40 is located 32 bytes to the left of global variable '(anonymous namespace)::autoRegistrar4' defined in '/home/tom/src/netket/Test/Hamiltonian/unit-matrixwrapper.cc:93:1' (0x200cf60) of size 8
0x00000200cf40 is located 24 bytes to the right of global variable '(anonymous namespace)::autoRegistrar1' defined in '/home/tom/src/netket/Test/Hamiltonian/unit-matrixwrapper.cc:71:1' (0x200cf20) of size 8
SUMMARY: AddressSanitizer: global-buffer-overflow /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_uninitialized.h in unsigned long* std::__uninitialized_copy<true>::__uninit_copy<std::move_iterator<unsigned long*>, unsigned long*>(std::move_iterator<unsigned long*>, std::move_iterator<unsigned long*>, unsigned long*)
Shadow bytes around the buggy address:
0x0000803f9990: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0000803f99a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0000803f99b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0000803f99c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0000803f99d0: 00 00 00 00 00 00 00 00 00 00 00 00 01 f9 f9 f9
=>0x0000803f99e0: f1 f1 f1 f1 00 f2 f2 f2[f9]f2 f2 f2 00 f2 f2 f2
0x0000803f99f0: 00 f3 f3 f3 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
0x0000803f9a00: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 f9 f9 f9
0x0000803f9a10: f9 f9 f9 f9 f1 f1 f1 f1 00 f2 f2 f2 00 f2 f2 f2
0x0000803f9a20: 00 f2 f2 f2 00 f3 f3 f3 00 00 00 00 00 00 00 00
0x0000803f9a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==27721==ABORTING