日期:2014-05-16  浏览次数:20761 次

C++编译问题
我用的程序可以运行得出结果后,会产生一个SIGABRT,请大家帮忙看看是什么原因,以下是用GDB调试产生的信息:
***   glibc   detected   ***   double   free   or   corruption   (!prev):   0x080892d8   ***
 
Program   received   signal   SIGABRT,   Aborted.
0x00b977a2   in   _dl_sysinfo_int80   ()   from   /lib/ld-linux.so.2
(gdb)   where
#0     0x00b977a2   in   _dl_sysinfo_int80   ()   from   /lib/ld-linux.so.2
#1     0x00bd77a5   in   raise   ()   from   /lib/tls/libc.so.6
#2     0x00bd9209   in   abort   ()   from   /lib/tls/libc.so.6
#3     0x00c0b72a   in   __libc_message   ()   from   /lib/tls/libc.so.6
#4     0x00c11fcf   in   _int_free   ()   from   /lib/tls/libc.so.6
#5     0x00c1234a   in   free   ()   from   /lib/tls/libc.so.6
#6     0x004dbe23   in   operator   delete   (ptr=0x0)
        at   ../../../gcc-3.2.3/libstdc++-v3/libsupc++/del_op.cc:39
#7     0x004c983c   in   std::__default_alloc_template <true,   0> ::deallocate   (
        __p=0x80892d8,   __n=6)
        at   /bes/soft/gcc/obj-3.2.3/i686-pc-linux-gnu/libstdc++-v3/include/bits/stl_a   lloc.h:113
#8     0x003e6bde   in   std::_Deque_base <zmex::ZMexception   const*,   std::allocator <zmex   ::ZMexception   const*>   > ::_M_destroy_nodes   (this=0x4503c0,   __nstart=0x80862e4,
        __nfinish=0x80862e8)   at   /usr/include/c++/3.2.3/bits/stl_alloc.h:248
#9     0x003e6aa9   in   ~_Deque_base   (this=0x4503c0)
        at   /usr/include/c++/3.2.3/bits/stl_deque.h:451
#10   0x003e652a   in   zmex::ZMerrnoList::~ZMerrnoList   ()
        at   /usr/include/c++/3.2.3/sstream:283
#11   0x0011632e   in   __tcf_1   ()   at   ZMerrno.cc:39
#12   0x00bda7a4   in   __cxa_finalize   ()   from   /lib/tls/libc.so.6
#13   0x00115c1d   in   __do_global_dtors_aux   ()
      from   /home/wuyh/work/ft/CLHEP/1.9.2.3/slc3_ia32_gcc323/lib/libCLHEP-Exception   ---Type   <return>   to   continue,   or   q   <return>   to   quit---
s-1.9.2.3.so
#14   0x0011a682   in   _fini   ()
      from   /home/wuyh/work/ft/CLHEP/1.9.2.3/slc3_ia32_gcc323/lib/libCLHEP-Exceptions-1.9.2.3.so
#15   0x00ba3907   in   _dl_fini   ()   from   /lib/ld-linux.so.2
#16   0x00bda527   in   exit   ()   from   /lib/tls/libc.so.6
#17   0x00bc4ded   in   __libc_start_main   ()   from   /lib/tls/libc.so.6
#18   0x0804b1c1   in   _start   ()


------解决方案--------------------
看看你的程序,可能其它地方有内存越界的操作。
------解决方案--------------------
举两个例子:
1. 越界产生段错误
#include "string.h "
int main()
{
char *a=new char[2];
strcpy(a, "this is a test\n ");
delete a;
}
2. double free
int main()
{
char *a=new char[100];
strcpy(a, "this is a test\n ");
del