xxsds / DYNAMIC

Dynamic succinct/compressed data structures
MIT License
111 stars 21 forks source link

Bug: Construction of list of rle_str with specified alphabet size fails (segmentation fault). #17

Closed jendas1 closed 5 years ago

jendas1 commented 5 years ago

Hi, I wanted to use multiple of rle_str, but I get segmentation fault when constructing the vector. Here is MWE:

#include <dynamic.hpp>

using namespace std;
using namespace dyn;

int main() {
    vector<rle_str> strs(2,rle_str(5));
    return 0;
}

Reproduced the bug on both clang-8 and gcc-8. When constructing without the specified alphabet size vector<rle_str> strs(2) everything works fine. What is strange that this pointer is NULL which was assigned in node(const node& other) constructor.

Thank you for the effort of creating this library. Jan

Stacktrace:

dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > >::node::operator= wt_string.hpp:305
dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > >::node::operator= wt_string.hpp:305
dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > >::node::node wt_string.hpp:301
dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > >::wt_string wt_string.hpp:32
dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > >::rle_string rle_string.hpp:28
std::_Construct<dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > >, dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > > const&> stl_construct.h:75
std::__uninitialized_fill_n<false>::__uninit_fill_n<dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > >*, unsigned long, dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > > > stl_uninitialized.h:210
std::uninitialized_fill_n<dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > >*, unsigned long, dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > > > stl_uninitialized.h:255
std::__uninitialized_fill_n_a<dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > >*, unsigned long, dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > >, dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > > > stl_uninitialized.h:366
std::vector<dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > >, std::allocator<dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > > > >::_M_fill_initialize stl_vector.h:1480
std::vector<dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > >, std::allocator<dyn::rle_string<dyn::gap_bitvector<dyn::spsi<dyn::packed_vector, 256u, 16u> >, dyn::wt_string<dyn::succinct_bitvector<dyn::spsi<dyn::packed_vector, 8192u, 16u> > > > > >::vector stl_vector.h:430
main test_size.cpp:7
__libc_start_main 0x00007f4a41191830
_start 0x0000000000429099
nicolaprezza commented 5 years ago

Hi, thanks for spotting this bug! it was a problem in the copy constructor of wt_str, which was not defined correctly. Now it should work.