当我使用CPPUNIT_ASSERT时会发生Segfault核心转储

问题描述

我最近更新到fedora30。现在运行测试时,我的代码将核心转储到消息的描述符的CPPUNIT_ASSERT中,

gcc版本:

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版本:

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

回溯:

#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::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::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::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::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::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::allocator<char> >*,std::__cxx11::basic_str
ing<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::allocator<char> >,std::allocator<std::__cxx11
::basic_string<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

在第708行删除CPPUNIT_ASSERT可使测试顺利通过-包括上述转储在内的核心转储。 __first和__last的值是“”-不确定是否会导致转储。我以为我的版本已关闭,但不确定。有任何建议吗?

编辑:

此特定测试的核心转储行:

CPPUNIT_ASSERT(correctHashes != 0);

此核心转储发生在使用CPPUNIT_ASSERT的任何测试中

解决方法

从fc32存储库升级到cppunit 1.15可以解决我的问题。