std::vector 析构的时候core掉

alienyu0352 2016-12-08 06:39:27
*** glibc detected *** SettRate: free(): invalid pointer: 0x0000000000aaafd0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x75018)[0x7f8b9df2b018]
/lib64/libc.so.6(cfree+0x6c)[0x7f8b9df2ff6c]
/home/sett13/QuickMDB/lib/libmdbInterface.so(_ZN12TMdbRollbackD1Ev+0x1c1)[0x7f8ba0f734d7]
/home/sett13/QuickMDB/lib/libmdbInterface.so(_ZN12TMdbDatabase10DisconnectEv+0x83)[0x7f8ba0f59301]
/home/sett13/QuickMDB/lib/libmdbInterface.so(_ZN12TMdbDatabaseD1Ev+0x16)[0x7f8ba0f59444]
/home/sett13/settv80/lib/libsettappcomm.so(_ZN13TAppComponent7cleanupEv+0x1a)[0x7f8ba0823d2a]
/home/sett13/settv80/lib/libsettappcomm.so(_ZN13TAppComponentD2Ev+0x24)[0x7f8ba08244d4]
/home/sett13/settv80/lib/libsettappcomm.so(_ZN16TBaseApplicationD2Ev+0x321)[0x7f8ba0827571]
SettRate[0x41ce17]
SettRate[0x423a8c]
/lib64/libc.so.6(__libc_start_main+0xe6)[0x7f8b9ded4bc6]
SettRate[0x410ca9]
======= Memory map: ========
00400000-0053a000 r-xp 00000000 fd:01 164982 /home/sett13/settv80/bin/SettRate
0073a000-0073c000 r--p 0013a000 fd:01 164982 /home/sett13/settv80/bin/SettRate
0073c000-00764000 rw-p 0013c000 fd:01 164982 /home/sett13/settv80/bin/SettRate
00764000-00bac000 rw-p 00000000 00:00 0 [heap]
7f8af8000000-7f8af8021000 rw-p 00000000 00:00 0
7f8af8021000-7f8afc000000 ---p 00000000 00:00 0
7f8afccc4000-7f8afd51c000 rw-p 00000000 00:00 0
7f8afd51c000-7f8b1d51c000 rw-s 00000000 00:04 4325380 /SYSV0376831e (deleted)
7f8b1d51c000-7f8b3d51c000 rw-s 00000000 00:04 4292611 /SYSV03765c0e (deleted)
7f8b3d51c000-7f8b4d51c000 rw-s 00000000 00:04 4358149 /SYSV0376545d (deleted)
7f8b4d51c000-7f8b6d51c000 rw-s 00000000 00:04 4259842 /SYSV03765c2b (deleted)
7f8b6d51c000-7f8b8d51c000 rw-s 00000000 00:04 4227073 /SYSV03765c2a (deleted)
7f8b8d51c000-7f8b9d51c000 rw-s 00000000 00:04 4194304 /SYSV03765454 (deleted)
7f8b9d51c000-7f8b9d5e4000 r-xp 00000000 fd:04 176869 /usr/lib64/libstdc++.so.5.0.7
7f8b9d5e4000-7f8b9d7e3000 ---p 000c8000 fd:04 176869 /usr/lib64/libstdc++.so.5.0.7
7f8b9d7e3000-7f8b9d7e5000 r--p 000c7000 fd:04 176869 /usr/lib64/libstdc++.so.5.0.7
7f8b9d7e5000-7f8b9d7ec000 rw-p 000c9000 fd:04 176869 /usr/lib64/libstdc++.so.5.0.7
7f8b9d7ec000-7f8b9d7fe000 rw-p 00000000 00:00 0
7f8b9d7fe000-7f8b9d813000 r-xp 00000000 fd:00 57509 /lib64/libnsl-2.11.1.so
7f8b9d813000-7f8b9da12000 ---p 00015000 fd:00 57509 /lib64/libnsl-2.11.1.so
7f8b9da12000-7f8b9da13000 r--p 00014000 fd:00 57509 /lib64/libnsl-2.11.1.so
7f8b9da13000-7f8b9da14000 rw-p 00015000 fd:00 57509 /lib64/libnsl-2.11.1.so
7f8b9da14000-7f8b9da16000 rw-p 00000000 00:00 0
7f8b9da16000-7f8b9dd05000 r-xp 00000000 fd:06 436351 /oracle/product/102/lib/libnnz10.so
7f8b9dd05000-7f8b9de04000 ---p 002ef000 fd:06 436351 /oracle/product/102/lib/libnnz10.so
7f8b9de04000-7f8b9deb5000 rw-p 002ee000 fd:06 436351 /oracle/product/102/lib/libnnz10.so
7f8b9deb5000-7f8b9deb6000 rw-p 00000000 00:00 0
7f8b9deb6000-7f8b9e00a000 r-xp 00000000 fd:00 57555 /lib64/libc-2.11.1.so
7f8b9e00a000-7f8b9e20a000 ---p 00154000 fd:00 57555 /lib64/libc-2.11.1.so
7f8b9e20a000-7f8b9e20e000 r--p 00154000 fd:00 57555 /lib64/libc-2.11.1.so
7f8b9e20e000-7f8b9e20f000 rw-p 00158000 fd:00 57555 /lib64/libc-2.11.1.so
7f8b9e20f000-7f8b9e214000 rw-p 00000000 00:00 0
7f8b9e214000-7f8b9e22a000 r-xp 00000000 fd:00 57361 /lib64/libgcc_s.so.1
7f8b9e22a000-7f8b9e429000 ---p 00016000 fd:00 57361 /lib64/libgcc_s.so.1
7f8b9e429000-7f8b9e42a000 r--p 00015000 fd:00 57361 /lib64/libgcc_s.so.1
7f8b9e42a000-7f8b9e42b000 rw-p 00016000 fd:00 57361 /lib64/libgcc_s.so.1
7f8b9e42b000-7f8b9e480000 r-xp 00000000 fd:00 57489 /lib64/libm-2.11.1.so
7f8b9e480000-7f8b9e67f000 ---p 00055000 fd:00 57489 /lib64/libm-2.11.1.so
7f8b9e67f000-7f8b9e680000 r--p 00054000 fd:00 57489 /lib64/libm-2.11.1.so
7f8b9e680000-7f8b9e681000 rw-p 00055000 fd:00 57489 /lib64/libm-2.11.1.so
7f8b9e681000-7f8b9e771000 r-xp 00000000 fd:04 176641 /usr/lib64/libstdc++.so.6.0.10
7f8b9e771000-7f8b9e970000 ---p 000f0000 fd:04 176641 /usr/lib64/libstdc++.so.6.0.10
7f8b9e970000-7f8b9e977000 r--p 000ef000 fd:04 176641 /usr/lib64/libstdc++.so.6.0.10
7f8b9e977000-7f8b9e979000 rw-p 000f6000 fd:04 176641 /usr/lib64/libstdc++.so.6.0.10
7f8b9e979000-7f8b9e98c000 rw-p 00000000 00:00 0
7f8b9e98c000-7f8b9e990000 r-xp 00000000 fd:01 680047 /home/sett13/settv80/lib/libsettpreplus_selfdef.so
7f8b9e990000-7f8b9eb8f000 ---p 00004000 fd:01 680047 /home/sett13/settv80/lib/libsettpreplus_selfdef.so
7f8b9eb8f000-7f8b9eb90000 r--p 00003000 fd:01 680047 /home/sett13/settv80/lib/libsettpreplus_selfdef.so
7f8b9eb90000-7f8b9eb91000 rw-p 00004000 fd:01 680047 /home/sett13/settv80/lib/libsettpreplus_selfdef.so
7f8b9eb91000-7f8b9ef61000 rw-p 00000000 00:00 0
7f8b9ef61000-7f8b9ef63000 r-xp 00000000 fd:01 680049 /home/sett13/settv80/lib/libsettproc_cdr_module.so
7f8b9ef63000-7f8b9f163000 ---p 00002000 fd:01 680049 /home/sett13/settv80/lib/libsettproc_cdr_module.so
7f8b9f163000-7f8b9f164000 r--p 00002000 fd:01 680049 /home/sett13/settv80/lib/libsettproc_cdr_module.so
7f8b9f164000-7f8b9f165000 rw-p 00003000 fd:01 680049 /home/sett13/settv80/lib/libsettproc_cdr_module.soAborted

最上面的地址0x0000000000aaafd0 是std::vector<int> 里面出错的free的地址。


问题:
标准库的vector是否存在内存管理的漏洞,还是代码存在某种bug,导致内存被不明数据踩到了
...全文
767 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
金士顿 2018-12-08
  • 打赏
  • 举报
回复
我遇到过这个错误,是char *p = new char(len + 1)这个错了
应该是char *p = new char[len + 1]
ipqtjmqj 2016-12-09
  • 打赏
  • 举报
回复
标准库的析构函数不是virtual的,所以如果你继承并base *p = new derived();这样再delete就会出错
赵4老师 2016-12-09
  • 打赏
  • 举报
回复
free Deallocates or frees a memory block. void free( void *memblock ); Function Required Header Compatibility free <stdlib.h> and <malloc.h> ANSI, Win 95, Win NT For additional compatibility information, see Compatibility in the Introduction. Libraries LIBC.LIB Single thread static library, retail version LIBCMT.LIB Multithread static library, retail version MSVCRT.LIB Import library for MSVCRT.DLL, retail version Return Value None Parameter memblock Previously allocated memory block to be freed Remarks The free function deallocates a memory block (memblock) that was previously allocated by a call to calloc, malloc, or realloc. The number of freed bytes is equivalent to the number of bytes requested when the block was allocated (or reallocated, in the case of realloc). If memblock is NULL, the pointer is ignored and free immediately returns. Attempting to free an invalid pointer (a pointer to a memory block that was not allocated by calloc, malloc, or realloc) may affect subsequent allocation requests and cause errors. After a memory block has been freed, _heapmin minimizes the amount of free memory on the heap by coalescing the unused regions and releasing them back to the operating system. Freed memory that is not released to the operating system is restored to the free pool and is available for allocation again. When the application is linked with a debug version of the C run-time libraries, free resolves to _free_dbg. For more information about how the heap is managed during the debugging process, see Using C Run-Time Library Debugging Support. Example /* MALLOC.C: This program allocates memory with * malloc, then frees the memory with free. */ #include <stdlib.h> /* For _MAX_PATH definition */ #include <stdio.h> #include <malloc.h> void main( void ) { char *string; /* Allocate space for a path name */ string = malloc( _MAX_PATH ); if( string == NULL ) printf( "Insufficient memory available\n" ); else { printf( "Memory space allocated for path name\n" ); free( string ); printf( "Memory freed\n" ); } } Output Memory space allocated for path name Memory freed Memory Allocation Routines See Also _alloca, calloc, malloc, realloc, _free_dbg, _heapmin
paschen 2016-12-08
  • 打赏
  • 举报
回复
首先怀疑的是你的代码,而不是一个成熟的标准库

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧