louisdx / cxx-prettyprint

A header-only library for C++(0x) that allows automagic pretty-printing of any container.
http://louisdx.github.com/cxx-prettyprint/
Boost Software License 1.0
556 stars 72 forks source link

Segmentation fault on bucket print (last) in ppdemo.cpp (default compile command on MacOS) #25

Open ktsiam opened 5 years ago

Alexander-Shukaev commented 5 years ago

Call stack traceback?

ktsiam commented 5 years ago

It's when I call it with no arguments. If I call it with arguments it works fine.

Valgrind output: ==64859== Memcheck, a memory error detector ==64859== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==64859== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==64859== Command: ./ppdemo ==64859== Printing pairs. Vector: [] Incremental vector: [] Pairs: [] Another vector: || || Set: {} OMap: [] UMap: [] String: Array: [h, e, l, l, o] Valarray: [1, -0.5, 0.25, -0.125] Reusable delimiters: <> Custom, type-erased delimiters: <> Custom, type-erased delimiters: <1729> Custom, type-erased delimiters: <Qrgh; (Jello, 9); 11> Static C array: [1, 4, 9, 16] Static C array: [2] Static C array with length: [4, 9] Pair: (Jello, 9) 0-tuple: () 1-tuple: (1729) n-tuple: (Qrgh, (Jello, 9), 11) n-tuple: (1729, 2875, (1.5, abc)) ==64859== Invalid read of size 8 ==64859== at 0x100005DD3: pretty_print::print_container_helper<pretty_print::bucket_print_wrapper<std::1::unordered_map<int, std::__1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::hash, std::1::equal_to, std::1::allocator<std::1::pair<int const, std::__1::basic_string<char, std::1::char_traits, std::1::allocator > > > > >, char, std::1::char_traits, pretty_print::delimiters<pretty_print::bucket_print_wrapper<std::1::unordered_map<int, std::__1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::hash, std::1::equal_to, std::1::allocator<std::1::pair<int const, std::__1::basic_string<char, std::1::char_traits, std::1::allocator > > > > >, char> >::printer<pretty_print::bucket_print_wrapper<std::__1::unordered_map<int, std::1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::hash, std::__1::equal_to, std::1::allocator<std::1::pair<int const, std::1::basic_string<char, std::1::char_traits, std::1::allocator > > > > > >::print_body(pretty_print::bucket_print_wrapper<std::1::unordered_map<int, std::1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::hash, std::__1::equal_to, std::1::allocator<std::1::pair<int const, std::1::basic_string<char, std::1::char_traits, std::1::allocator > > > > > const&, std::1::basic_ostream<char, std::1::char_traits >&) (in ./ppdemo) ==64859== by 0x1000026CC: main (in ./ppdemo) ==64859== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==64859== ==64859== ==64859== Process terminating with default action of signal 11 (SIGSEGV) ==64859== Access not within mapped region at address 0x0 ==64859== at 0x100005DD3: pretty_print::print_container_helper<pretty_print::bucket_print_wrapper<std::1::unordered_map<int, std::__1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::hash, std::1::equal_to, std::1::allocator<std::1::pair<int const, std::__1::basic_string<char, std::1::char_traits, std::1::allocator > > > > >, char, std::1::char_traits, pretty_print::delimiters<pretty_print::bucket_print_wrapper<std::1::unordered_map<int, std::__1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::hash, std::1::equal_to, std::1::allocator<std::1::pair<int const, std::__1::basic_string<char, std::1::char_traits, std::1::allocator > > > > >, char> >::printer<pretty_print::bucket_print_wrapper<std::__1::unordered_map<int, std::1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::hash, std::__1::equal_to, std::1::allocator<std::1::pair<int const, std::1::basic_string<char, std::1::char_traits, std::1::allocator > > > > > >::print_body(pretty_print::bucket_print_wrapper<std::1::unordered_map<int, std::1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::hash, std::__1::equal_to, std::1::allocator<std::1::pair<int const, std::1::basic_string<char, std::1::char_traits, std::1::allocator > > > > > const&, std::1::basic_ostream<char, std::1::char_traits >&) (in ./ppdemo) ==64859== by 0x1000026CC: main (in ./ppdemo) ==64859== If you believe this happened as a result of a stack ==64859== overflow in your program's main thread (unlikely but ==64859== possible), you can try to increase the size of the ==64859== main thread stack using the --main-stacksize= flag. ==64859== The main thread stack size used in this run was 8388608. ==64859== ==64859== HEAP SUMMARY: ==64859== in use at exit: 22,785 bytes in 167 blocks ==64859== total heap usage: 191 allocs, 24 frees, 31,281 bytes allocated ==64859== ==64859== LEAK SUMMARY: ==64859== definitely lost: 0 bytes in 0 blocks ==64859== indirectly lost: 0 bytes in 0 blocks ==64859== possibly lost: 72 bytes in 3 blocks ==64859== still reachable: 4,476 bytes in 11 blocks ==64859== suppressed: 18,237 bytes in 153 blocks ==64859== Rerun with --leak-check=full to see details of leaked memory ==64859== ==64859== For counts of detected and suppressed errors, rerun with: -v ==64859== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 1 from 1) Segmentation fault: 11