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

crash: doctest with custom allocator #382

Closed
blockspacer opened this issue May 29, 2020 · 3 comments
Closed

crash: doctest with custom allocator #382

blockspacer opened this issue May 29, 2020 · 3 comments

Comments

@blockspacer
Copy link

blockspacer commented May 29, 2020

crash with alloc shim as allocator (chromium based), https://github.com/blockspacer/chromium_base_conan

crash on doctest::Context destruction

How to reproduce:
used basis lib on commit blockspacer/basis@484752d
used flexlib lib on commit
blockspacer/flexlib@2695724
used base/allocator/allocator_shim.cc on commit
https://github.com/blockspacer/chromium_base_conan/blob/8e45a5dc6abfc06505fd660c08ad43c592daf5aa/base/allocator/allocator_shim.cc

related files:
flexlib/tests/doctest.test.cpp
basis/basis/doctest_util.cc

How to build with chromium based alloc shim: conan create as usual for all required deps, see blockspacer/chromium_base_conan#1 (comment)

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

clang-6.0 --version
clang version 6.0.1-svn334776-1~exp1~20190309042730.123 (branches/release_60)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
gdb -ex r -ex bt --args ~/.conan/data/flexlib/master/conan/stable/build/4226740ff13976194d38b9971d813a7121a397d6/bin/Debug/tests/flexlib-doctest "--duration=1"

Program received signal SIGSEGV, Segmentation fault.
doctest::String::isOnStack (this=0xffff800013b8319b)
    at~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:470
470         bool isOnStack() const { return (buf[last] & 128) == 0; }
#0  doctest::String::isOnStack (this=0xffff800013b8319b)
    at~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:470
#1  0x00000000008c3a29 in doctest::String::~String (this=0xffff800013b8319b)
    at~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:3050
#2  0x00000000008db335 in std::_Destroy<doctest::String> (__pointer=0xffff800013b8319b)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_construct.h:98
#3  0x00000000008db2ff in std::_Destroy_aux<false>::__destroy<doctest::String*> (__first=0xffff800013b8319b, __last=0xfffffffffffffcbb)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_construct.h:108
#4  0x00000000008db2bd in std::_Destroy<doctest::String*> (__first=0xffff800013b8319b, __last=0xfffffffffffffcbb)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_construct.h:136
#5  0x00000000008db201 in std::_Destroy<doctest::String*, doctest::String> (__first=0xffff800013b8319b, __last=0xfffffffffffffcbb)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_construct.h:206
#6  0x00000000008db1a8 in std::vector<doctest::String, std::allocator<doctest::String> >::~vector (this=0x7fffec47ce00)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_vector.h:434
#7  0x00000000008db165 in std::_Destroy<std::vector<doctest::String, std::allocator<doctest::String> > > (__pointer=0x7fffec47ce00)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_construct.h:98
#8  0x00000000008db12f in std::_Destroy_aux<false>::__destroy<std::vector<doctest::String, std::allocator<doctest::String> >*> (__first=0x7fffec47ce00, 
    __last=0x7fffec47ced8) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_construct.h:108
--Type <RET> for more, q to quit, c to continue without paging--
#9  0x00000000008db0ed in std::_Destroy<std::vector<doctest::String, std::allocator<doctest::String> >*> (__first=0x7fffec47ce00, __last=0x7fffec47ced8)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_construct.h:136
#10 0x00000000008dc131 in std::_Destroy<std::vector<doctest::String, std::allocator<doctest::String> >*, std::vector<doctest::String, std::allocator<doctest::String> > > (__first=0x7fffec47ce00, __last=0x7fffec47ced8) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_construct.h:206
#11 0x00000000008db8b8 in std::vector<std::vector<doctest::String, std::allocator<doctest::String> >, std::allocator<std::vector<doctest::String, std::allocator<doctest::String> > > >::~vector (this=0x7fffec43ee40) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_vector.h:434
#12 0x00000000008d8cdd in doctest::detail::ContextState::~ContextState (this=0x7fffec43ed80)
    at~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:2941
#13 0x00000000008cab2f in doctest::Context::~Context (this=0x7fffffffd4b8)
    at~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:5552
#14 0x000000000040ea1b in main (argc=2, argv=0x7fffffffd888)
    at~/.conan/data/flexlib/master/conan/stable/build/4226740ff13976194d38b9971d813a7121a397d6/tests/main.cpp:196
blockspacer pushed a commit to blockspacer/flexlib that referenced this issue May 29, 2020
@blockspacer
Copy link
Author

blockspacer commented May 29, 2020

Program received signal SIGSEGV, Segmentation fault.
doctest::String::isOnStack (this=0xffff800013b6f110)
    at ~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:470
470         bool isOnStack() const { return (buf[last] & 128) == 0; }
(gdb) bt

#0  doctest::String::isOnStack (this=0xffff800013b6f110)
    at ~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:470
#1  0x0000000000ac2f99 in doctest::String::c_str (this=0xffff800013b6f110)
    at ~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:499
#2  0x0000000000ac2e75 in doctest::String::c_str (this=0xffff800013b6f110)
    at ~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:497
#3  0x0000000000ab18a8 in doctest::(anonymous namespace)::matchesAny (
    name=0x7fffec479ea0 "~/.conan/data/flexlib/master/conan/stable/build/4226740ff13976194d38b9971d813a7121a397d6/include/flexlib/funcParser.hpp", 
    filters=std::vector of length 5864048233249, capacity 5864048233290 = {...}, matchEmpty=true, caseSensitive=false)
    at ~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:3535
#4  0x0000000000ab70ce in doctest::Context::run (this=0x7fffffffd6e0)
    at ~/.conan/data/doctest/2.3.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/doctest/doctest.h:5825
#5  0x00000000004cfb65 in main (argc=1, argv=0x7fffffffd898)
    at ~/.conan/data/flexlib/master/conan/stable/build/4226740ff13976194d38b9971d813a7121a397d6/tests/main.cpp:235

@onqtam
Copy link
Member

onqtam commented Jun 4, 2020

Well... one weird thing that I see is this: filters=std::vector of length 5864048233249, capacity 5864048233290 - thats one big std::vector... There is some memory corruption somewhere - I don't think that the problem is in doctest::String but I also cannot think of a reason why the filters container would be corrupted - the doctest::Context class doesn't do anything too fancy with it...

However I don't have the capacity to build your project and try to debug this ATM - I would appreciate if you try that, or if you provide a truly minimalistic example which would reproduce the problem.

@blockspacer
Copy link
Author

@onqtam Thanks for response.

Issue may be not doctest-related. I'll re-open it if problem is doctest-related.

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

No branches or pull requests

2 participants