"(...) points to uninitialised byte(s) (...) " under valgrind
Runing the code under valgrind, store_to_file(...) may lead to a:
"Syscall param writev(vector[...]) points to uninitialised byte(s) (...) "
The code that can trigger the problem is: //
include <sdsl/suffix_trees.hpp>
include
using namespace sdsl; using namespace std;
int main() { csa_wt<wt_huff<rrr_vector<127> >, 512, 1024> index; string index_filename = "tmp_file"; construct(index, "problem_input", 1); std::cout << "Index constructed" << std::endl; store_to_file(index, index_filename); std::cout << "Done." << std::endl; } //
And an input that triggers it is here: https://www.cs.helsinki.fi/u/dvalenzu/tmp/bug/problem_input I run into this on release 2.0.3, but I have just verified that the behavior is the same in the latest release.
If you cannot reproduce it I'll be happy to provide more details,
Best, Daniel
Hi Daniel, thanks for letting me know. Best, Simon
If I run this code:
#include "sdsl/suffix_arrays.hpp"
using namespace sdsl;
using namespace std;
int main()
{
csa_wt<> index;
string index_filename = "tmp_file";
construct(index, "problem_input", 1);
std::cout << "Index constructed" << std::endl;
store_to_file(index, index_filename);
std::cout << "Done." << std::endl;
}
I don't get any leaks:
[mpetri@haathee ../examples]$ valgrind ./test.x
==24059== Memcheck, a memory error detector
==24059== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==24059== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==24059== Command: ./test.x
==24059==
Index constructed
Done.
==24059==
==24059== HEAP SUMMARY:
==24059== in use at exit: 72,704 bytes in 1 blocks
==24059== total heap usage: 1,452 allocs, 1,451 frees, 6,882,262 bytes allocated
==24059==
==24059== LEAK SUMMARY:
==24059== definitely lost: 0 bytes in 0 blocks
==24059== indirectly lost: 0 bytes in 0 blocks
==24059== possibly lost: 0 bytes in 0 blocks
==24059== still reachable: 72,704 bytes in 1 blocks
==24059== suppressed: 0 bytes in 0 blocks
==24059== Rerun with --leak-check=full to see details of leaked memory
==24059==
==24059== For counts of detected and suppressed errors, rerun with: -v
==24059== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Hi, I'm sory that my code was posted without proper formatting, the actual code is here https://www.cs.helsinki.fi/u/dvalenzu/tmp/bug/construct-in-memory.cpp It is slightly different than yours (using a specific csa / wt_huff / rrr / 127, 512, 1024 .... (in the process of realizing why your code didn't throw the error I made another setup to reproduce it in a CI enviroment here: https://gitlab.com/dvalenzu/sdsl_border_case/builds/2364218 ) Best, Daniel
with this new example, I get the following valgrind output:
[mpetri@umelb-168-918 ../examples]$ valgrind ./construct-in-memory.x
==2224== Memcheck, a memory error detector
==2224== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==2224== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==2224== Command: ./construct-in-memory.x
==2224==
==2224== Conditional jump or move depends on uninitialised value(s)
==2224== at 0x41470E: bool sdsl::load_vector_from_file<sdsl::int_vector<(unsigned char)8> >(sdsl::int_vector<(unsigned char)8>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char, unsigned char) (in /home/mpetri/data/dev/sdsl-lite/examples/construct-in-memory.x)
==2224== by 0x4193BF: void sdsl::construct<sdsl::csa_wt<sdsl::wt_pc<sdsl::huff_shape, sdsl::rrr_vector<(unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::rank_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)0, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::byte_tree<false> >, 512u, 1024u, sdsl::sa_order_sa_sampling<(unsigned char)0>, sdsl::isa_sampling<(unsigned char)0>, sdsl::byte_alphabet> >(sdsl::csa_wt<sdsl::wt_pc<sdsl::huff_shape, sdsl::rrr_vector<(unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::rank_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)0, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::byte_tree<false> >, 512u, 1024u, sdsl::sa_order_sa_sampling<(unsigned char)0>, sdsl::isa_sampling<(unsigned char)0>, sdsl::byte_alphabet>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sdsl::cache_config&, unsigned char, sdsl::csa_tag) (in /home/mpetri/data/dev/sdsl-lite/examples/construct-in-memory.x)
==2224== by 0x41A128: void sdsl::construct<sdsl::csa_wt<sdsl::wt_pc<sdsl::huff_shape, sdsl::rrr_vector<(unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::rank_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)0, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::byte_tree<false> >, 512u, 1024u, sdsl::sa_order_sa_sampling<(unsigned char)0>, sdsl::isa_sampling<(unsigned char)0>, sdsl::byte_alphabet> >(sdsl::csa_wt<sdsl::wt_pc<sdsl::huff_shape, sdsl::rrr_vector<(unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::rank_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)0, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::byte_tree<false> >, 512u, 1024u, sdsl::sa_order_sa_sampling<(unsigned char)0>, sdsl::isa_sampling<(unsigned char)0>, sdsl::byte_alphabet>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char) (in /home/mpetri/data/dev/sdsl-lite/examples/construct-in-memory.x)
==2224== by 0x404756: main (in /home/mpetri/data/dev/sdsl-lite/examples/construct-in-memory.x)
==2224==
==2224== Conditional jump or move depends on uninitialised value(s)
==2224== at 0x414725: bool sdsl::load_vector_from_file<sdsl::int_vector<(unsigned char)8> >(sdsl::int_vector<(unsigned char)8>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char, unsigned char) (in /home/mpetri/data/dev/sdsl-lite/examples/construct-in-memory.x)
==2224== by 0x4193BF: void sdsl::construct<sdsl::csa_wt<sdsl::wt_pc<sdsl::huff_shape, sdsl::rrr_vector<(unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::rank_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)0, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::byte_tree<false> >, 512u, 1024u, sdsl::sa_order_sa_sampling<(unsigned char)0>, sdsl::isa_sampling<(unsigned char)0>, sdsl::byte_alphabet> >(sdsl::csa_wt<sdsl::wt_pc<sdsl::huff_shape, sdsl::rrr_vector<(unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::rank_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)0, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::byte_tree<false> >, 512u, 1024u, sdsl::sa_order_sa_sampling<(unsigned char)0>, sdsl::isa_sampling<(unsigned char)0>, sdsl::byte_alphabet>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sdsl::cache_config&, unsigned char, sdsl::csa_tag) (in /home/mpetri/data/dev/sdsl-lite/examples/construct-in-memory.x)
==2224== by 0x41A128: void sdsl::construct<sdsl::csa_wt<sdsl::wt_pc<sdsl::huff_shape, sdsl::rrr_vector<(unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::rank_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)0, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::byte_tree<false> >, 512u, 1024u, sdsl::sa_order_sa_sampling<(unsigned char)0>, sdsl::isa_sampling<(unsigned char)0>, sdsl::byte_alphabet> >(sdsl::csa_wt<sdsl::wt_pc<sdsl::huff_shape, sdsl::rrr_vector<(unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::rank_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)1, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::select_support_rrr<(unsigned char)0, (unsigned short)127, sdsl::int_vector<(unsigned char)0>, (unsigned short)32>, sdsl::byte_tree<false> >, 512u, 1024u, sdsl::sa_order_sa_sampling<(unsigned char)0>, sdsl::isa_sampling<(unsigned char)0>, sdsl::byte_alphabet>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char) (in /home/mpetri/data/dev/sdsl-lite/examples/construct-in-memory.x)
==2224== by 0x404756: main (in /home/mpetri/data/dev/sdsl-lite/examples/construct-in-memory.x)
==2224==
Index construced
Done.
==2224==
==2224== HEAP SUMMARY:
==2224== in use at exit: 72,704 bytes in 1 blocks
==2224== total heap usage: 441 allocs, 440 frees, 6,497,337 bytes allocated
==2224==
==2224== LEAK SUMMARY:
==2224== definitely lost: 0 bytes in 0 blocks
==2224== indirectly lost: 0 bytes in 0 blocks
==2224== possibly lost: 0 bytes in 0 blocks
==2224== still reachable: 72,704 bytes in 1 blocks
==2224== suppressed: 0 bytes in 0 blocks
==2224== Rerun with --leak-check=full to see details of leaked memory
==2224==
==2224== For counts of detected and suppressed errors, rerun with: -v
==2224== Use --track-origins=yes to see where uninitialised values come from
==2224== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)