Search code examples
c++gccfedoracoredumpcppunit

Segfault coredump occurs when I use CPPUNIT_ASSERT


I recently updated to fedora 30. When running a test now, my code will coredump on the CPPUNIT_ASSERT in the destrctor of the Message,

gcc version:

gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Cppunit version:

Installed Packages
cppunit.x86_64                                                       1.14.0-7.fc30                                                        @fedora

backtrace:

#0  0x00007ff037a363ff in free () from /lib64/libjemalloc.so.2

#1  0x000000000044ea37 in __gnu_cxx::new_allocator<char>::deallocate (this=0x7ff02fefc000, __p=0x1 <error: Cannot access memory at address 0x1>)
at /usr/include/c++/9/ext/new_allocator.h:128

#2  0x000000000044cc39 in std::allocator_traits<std::allocator<char> >::deallocate (__a=..., __p=0x1 <error: Cannot access memory at address 0x1>
, __n=70999306) at /usr/include/c++/9/bits/alloc_traits.h:470

#3  0x000000000043eb9f in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_destroy (this=0x7ff02fefc000, __siz
e=70999305) at /usr/include/c++/9/bits/basic_string.h:237

#4  0x000000000043df95 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose (this=0x7ff02fefc000) at /u
sr/include/c++/9/bits/basic_string.h:232

#5  0x000000000043b9a5 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string (this=0x7ff02fefc000, __
in_chrg=<optimized out>) at /usr/include/c++/9/bits/basic_string.h:658

#6  0x0000000000738397 in std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (__pointer=0x7ff02fefc0
00) at /usr/include/c++/9/bits/stl_construct.h:98

#7  0x00000000007359f9 in std::_Destroy_aux<false>::__destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*> (
__first=0x7ff02fefc000, __last=0x7ff02fefb460) at /usr/include/c++/9/bits/stl_construct.h:108

#8  0x00000000007326a2 in std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*> (__first=0x7ff02fefb5e0
, __last=0x7ff02fefb460) at /usr/include/c++/9/bits/stl_construct.h:137

#9  0x000000000072fb65 in std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_str
ing<char, std::char_traits<char>, std::allocator<char> > > (__first=0x7ff02fefb5e0, __last=0x7ff02fefb460) at /usr/include/c++/9/bits/stl_constru
ct.h:206

#10 0x000000000075d72d in std::deque<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11
::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::_M_destroy_data_aux (this=0x7fffdd38c658, __first="", __last=non-derefer
enceable iterator for std::deque) at /usr/include/c++/9/bits/deque.tcc:864

#11 0x00007ff0384e52ed in CppUnit::Message::~Message() () from /lib64/libcppunit-1.14.so.0

#12 0x0000000000ed4ac8 in UT_MyTest::basic(this=0x7ff034b294b0, chunks=std::vector of lengt
h 1000, capacity 1024 = {...}, index=...) at /home/felix/git/master/src/core/UT_MyTest.cpp:708

Removing the CPPUNIT_ASSERT on line 708 enables the test to pass without issue - including it coredumps with this dump above. The values of __first and __last are "" - not sure if that will cause it to dump. I'm thinking my versioning is off, but I'm not sure. Has anyone any suggestions?

Edit:

The line it coredumps on for this particular test:

CPPUNIT_ASSERT(correctHashes != 0);

This coredump happens in any test that use CPPUNIT_ASSERT


Solution

  • Upgrading to cppunit 1.15 from the fc32 repo fixed the issue for me.