C++ malloc_合并中的SIGABRT-函数是否可能返回NULL?
我使用以下代码登录ARM:C++ malloc_合并中的SIGABRT-函数是否可能返回NULL?,c++,C++,我使用以下代码登录ARM: template <typename T> MyClass& operator<<(T const& t) { try { m_buffer << t; } catch (...) { /* No exceptions */ } return *this; } 有了瓦尔格林,我看不到任何奇怪的东西 LE:在中止过程中会打印以下消
template <typename T>
MyClass& operator<<(T const& t)
{
try
{
m_buffer << t;
}
catch (...)
{
/* No exceptions */
}
return *this;
}
有了瓦尔格林,我看不到任何奇怪的东西
LE:在中止过程中会打印以下消息:
malloc.c:5345:malloc\u合并:断言'p->fd\u nextsize->bk\u nextsize==p'失败
GCC文档清楚地表明,\u函数
为您提供了未经修饰的函数名称。失败的唯一方法是,如果您不在函数中
很可能你在其他地方有UB,但就像现在的时尚一样,你没有提供UB,因此不可能有任何信心进一步帮助你。为什么不说
(\uuuu函数?\uu函数:“奇怪的空指针”)
并检查一下m\u缓冲区是什么?Astringstream
?如果是,哪个?是的,这是一个std::stringstream
。实际的崩溃是什么?错误信息是什么?第一个堆栈帧是什么?除了您使用的是stringstream之外,我们无法从中分辨出任何东西。它总是相同的崩溃吗?或者偶尔出现故障的唯一常见部分是new
/malloc()
还是delete
/free()
?如果是后者,则表示您在某个地方发生了堆损坏。事实上,这种情况只发生过一次。我添加了完整的回溯。当然,该语句用于函数中。实际上,它在流创建期间崩溃了:似乎是函数长度+空终止符。对不起,我误导了你
myClass <<__FUNCTION__<< " some string and int" << 5;
Program terminated with signal 6, Aborted.
#0 0x3695f46c in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:67
67 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) bt full
#0 0x3695f46c in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:67
pid = <value optimized out>
selftid = 1673
res = <value optimized out>
#1 0x36964d70 in *__GI_abort () at abort.c:92
act = {__sigaction_handler = {sa_handler = 0, sa_sigaction = 0}, sa_mask = {__val = {0 <repeats 32 times>}}, sa_flags = 0, sa_restorer = 0}
sigs = {__val = {32, 0 <repeats 31 times>}}
#2 0x369a3e4c in __malloc_assert (assertion=<value optimized out>, file=0x36a5f560 "malloc.c", line=<value optimized out>, function=<value optimized out>) at malloc.c:352
No locals.
#3 0x369a41c0 in malloc_consolidate (av=0x34781de0) at malloc.c:5345
fb = <value optimized out>
maxfb = 0x36a79288
p = 0x728818
nextp = 0x6ddec8
unsorted_bin = 0x36a7928c
first_unsorted = <value optimized out>
nextchunk = 0x728ac8
size = 688
nextsize = 880297072
prevsize = <value optimized out>
bck = <value optimized out>
fwd = 0xbec
__func__ = "malloc_consolidate"
#4 0x369a70d8 in _int_malloc (av=0x36a7925c, bytes=<value optimized out>) at malloc.c:4573
nb = <value optimized out>
idx = 1673
bin = <value optimized out>
victim = 0x36a78000
size = <value optimized out>
victim_index = <value optimized out>
remainder = <value optimized out>
remainder_size = <value optimized out>
block = <value optimized out>
bit = <value optimized out>
map = <value optimized out>
fwd = <value optimized out>
bck = <value optimized out>
errstr = <value optimized out>
__func__ = "_int_malloc"
#5 0x369a83d4 in _do_malloc (bytes=525) at malloc.c:4011
ar_ptr = 0x36a7925c
victim = <value optimized out>
__func__ = "_do_malloc"
#6 0x369aa0e8 in *__GI___libc_malloc (bytes=525) at malloc.c:3648
mem = <value optimized out>
#7 0x350b1f4c in operator new(unsigned int) () from /lib/libstdc++.so.6
No symbol table info available.
#8 0x3508f0e8 in std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) () from /lib/libstdc++.so.6
No symbol table info available.
#9 0x3508fa4c in std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned int) () from /lib/libstdc++.so.6
No symbol table info available.
#10 0x350905d0 in std::string::reserve(unsigned int) () from /lib/libstdc++.so.6
No symbol table info available.
#11 0x35089de4 in std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::overflow(int) () from /lib/libstdc++.so.6
No symbol table info available.
#12 0x3508e648 in std::basic_streambuf<char, std::char_traits<char> >::xsputn(char const*, int) () from /lib/libstdc++.so.6
No symbol table info available.
#13 0x35087604 in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int) () from /lib/libstdc++.so.6
No symbol table info available.
#14 0x35087958 in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) () from /lib/libstdc++.so.6
No symbol table info available.
#15 0x350e8974 in MyClass::operator<< <char [21]> (this=0x34782200, t=...) at ...