C++ 函数没写返回语句导致 munmap_chunk(): invalid pointer

vi@vi-Inspiron-7472:~/git/fip/src/build/bin$ ./test_vbase -t suite_vlog/case_info

C()

~C()

D()

~D()

Running 1 test case...

munmap_chunk(): invalid pointer

unknown location(0): fatal error: in "suite_vlog/case_info": signal: SIGABRT (application abort requested)

/home/vi/git/fip/src/test/test_vbase/suite_vlog.cpp(29): last checkpoint: "case_info" test entry

 

*** 1 failure is detected in the test module "test balance_mgr protocol_:wbuffer"

~D()

~C()

vi@vi-Inspiron-7472:~/git/fip/src/build/bin$ gdb ./test_vbase 

GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git

Copyright (C) 2018 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "x86_64-linux-gnu".

Type "show configuration" for configuration details.

For bug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>.

Find the GDB manual and other documentation resources online at:

<http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".

Type "apropos word" to search for commands related to "word"...

Reading symbols from ./test_vbase...done.

(gdb) r  -t suite_vlog/case_info

Starting program: /home/vi/git/fip/src/build/bin/test_vbase -t suite_vlog/case_info

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

C()

~C()

D()

~D()

Running 1 test case...

munmap_chunk(): invalid pointer

 

Program received signal SIGABRT, Aborted.

__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51

51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

(gdb) bt

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51

#1  0x00007ffff6ab48b1 in __GI_abort () at abort.c:79

#2  0x00007ffff6afd907 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff6c2adfa "%s\n") at ../sysdeps/posix/libc_fatal.c:181

#3  0x00007ffff6b0497a in malloc_printerr (str=str@entry=0x7ffff6c2ca08 "munmap_chunk(): invalid pointer") at malloc.c:5350

#4  0x00007ffff6b0bf3c in munmap_chunk (p=0x7fffffffcda0) at malloc.c:2846

#5  __GI___libc_free (mem=0x7fffffffcdb0) at malloc.c:3117

#6  0x000055555574c651 in suite_vlog::case_info::test_method (this=0x7fffffffccfe) at /home/vi/git/fip/src/test/test_vbase/suite_vlog.cpp:32

 

 

 

 

我们来看一下源代码是什么原因导致的:


std::string vlog::information()
{
bool is_multiple_th = true;
#if _VLOG_SUPPORT_THREAD_
is_multiple_th=true;
#else //#if _VLOG_SUPPORT_THREAD_
is_multiple_th=false;
#endif //end of #if _VLOG_SUPPORT_THREAD_

//std::cout<<get_level_str(_user_want_level);
//std::cout<<_map_tid_logstr.size();
//_oss.clear(); _oss.str("");
//std::cout<<"user setting log_level:"<<get_level_str(_user_want_level)<<","
// <<"multiple thread mode:"<<is_multiple_th<<","
// <<"map_logstr size:"<<_map_tid_logstr.size()<<std::endl;

}

本以为是多线程的问题,看了半天发现是函数没写返回语句。

 

上一篇:PHP大文件上传支持断点上传教程


下一篇:House_of_orange 学习小结