我收到此错误:“检测到 glibc"

I get this error: quot;glibc detectedquot;(我收到此错误:“检测到 glibc)

本文介绍了我收到此错误:“检测到 glibc"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚写了一段 CPP 代码,并在 ubuntu 中使用 G++ 编译了它.当我运行我的代码时,一切都很好,代码运行良好并提供输出但不退出并出现此错误:

<上一页>*** 检测到 glibc *** ./a.out: free(): 下一个大小无效(快速):0x09f931f0 ***======= 回溯:=========/lib/libc.so.6(+0x6c501)[0x3de501]/lib/libc.so.6(+0x6dd70)[0x3dfd70]/lib/libc.so.6(cfree+0x6d)[0x3e2e5d]/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x6e2441]./a.out[0x8049ce6]/lib/libc.so.6(+0x2f69e)[0x3a169e]/lib/libc.so.6(+0x2f70f)[0x3a170f]/lib/libc.so.6(__libc_start_main+0xef)[0x388cef]./a.out[0x8048a61]======= 内存映射:========00219000-0021a000 r-xp 00000000 00:00 0 [vdso]00354000-00370000 r-xp 00000000 08:01 8781845/lib/ld-2.12.1.so00370000-00371000 r--p 0001b000 08:01 8781845/lib/ld-2.12.1.so00371000-00372000 rw-p 0001c000 08:01 8781845/lib/ld-2.12.1.so00372000-004c9000 r-xp 00000000 08:01 8781869/lib/libc-2.12.1.so004c9000-004ca000 ---p 00157000 08:01 8781869/lib/libc-2.12.1.so004ca000-004cc000 r--p 00157000 08:01 8781869/lib/libc-2.12.1.so004cc000-004cd000 rw-p 00159000 08:01 8781869/lib/libc-2.12.1.so004cd000-004d0000 rw-p 00000000 00:00 000638000-00717000 r-xp 00000000 08:01 3935829/usr/lib/libstdc++.so.6.0.1400717000-0071b000 r--p 000de000 08:01 3935829/usr/lib/libstdc++.so.6.0.140071b000-0071c000 rw-p 000e2000 08:01 3935829/usr/lib/libstdc++.so.6.0.140071c000-00723000 rw-p 00000000 00:00 000909000-0092d000 r-xp 00000000 08:01 8781918/lib/libm-2.12.1.so0092d000-0092e000 r--p 00023000 08:01 8781918/lib/libm-2.12.1.so0092e000-0092f000 rw-p 00024000 08:01 8781918/lib/libm-2.12.1.so00fdb000-00ff5000 r-xp 00000000 08:01 8781903/lib/libgcc_s.so.100ff5000-00ff6000 r--p 00019000 08:01 8781903/lib/libgcc_s.so.100ff6000-00ff7000 rw-p 0001a000 08:01 8781903/lib/libgcc_s.so.108048000-0804b000 r-xp 00000000 08:01 8652645/home/akg/Desktop/contest/a.out0804b000-0804c000 r--p 00002000 08:01 8652645/home/akg/Desktop/contest/a.out0804c000-0804d000 rw-p 00003000 08:01 8652645/home/akg/Desktop/contest/a.out09f93000-09fb4000 rw-p 00000000 00:00 0 [堆]b7600000-b7621000 rw-p 00000000 00:00 0b7621000-b7700000 ---p 00000000 00:00 0b7765000-b7768000 rw-p 00000000 00:00 0b7775000-b7779000 rw-p 00000000 00:00 0bf9a7000-bf9c8000 rw-p 00000000 00:00 0 [堆栈]中止

这是什么意思?我怎样才能摆脱它?我没有使用 malloc 或 free ,我只是使用 vector !

解决方案

即使你不直接分配内存,它也发生在 vector 代码的底层,你很可能损坏了部分通过写你不应该写的地方来记忆.我能想到的最可能的原因是:

  1. 写入超出范围的元素
  2. 对不再有效的元素使用指针/引用 - 请注意,插入更多元素会使之前的引用无效

当然,除非您发布一些相关代码,否则我不能肯定地说.或者尝试使用 valgrind 来查找问题的根源.

I just wrote a piece of CPP code and I compiled it using G++ in ubuntu. When I run my code everything is fine, the code runs well and gives output but doesn't exit and it gives this error:

 *** glibc detected *** ./a.out: free(): invalid next size (fast): 0x09f931f0 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6c501)[0x3de501]
/lib/libc.so.6(+0x6dd70)[0x3dfd70]
/lib/libc.so.6(cfree+0x6d)[0x3e2e5d]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x6e2441]
./a.out[0x8049ce6]
/lib/libc.so.6(+0x2f69e)[0x3a169e]
/lib/libc.so.6(+0x2f70f)[0x3a170f]
/lib/libc.so.6(__libc_start_main+0xef)[0x388cef]
./a.out[0x8048a61]
======= Memory map: ========
00219000-0021a000 r-xp 00000000 00:00 0          [vdso]
00354000-00370000 r-xp 00000000 08:01 8781845    /lib/ld-2.12.1.so
00370000-00371000 r--p 0001b000 08:01 8781845    /lib/ld-2.12.1.so
00371000-00372000 rw-p 0001c000 08:01 8781845    /lib/ld-2.12.1.so
00372000-004c9000 r-xp 00000000 08:01 8781869    /lib/libc-2.12.1.so
004c9000-004ca000 ---p 00157000 08:01 8781869    /lib/libc-2.12.1.so
004ca000-004cc000 r--p 00157000 08:01 8781869    /lib/libc-2.12.1.so
004cc000-004cd000 rw-p 00159000 08:01 8781869    /lib/libc-2.12.1.so
004cd000-004d0000 rw-p 00000000 00:00 0 
00638000-00717000 r-xp 00000000 08:01 3935829    /usr/lib/libstdc++.so.6.0.14
00717000-0071b000 r--p 000de000 08:01 3935829    /usr/lib/libstdc++.so.6.0.14
0071b000-0071c000 rw-p 000e2000 08:01 3935829    /usr/lib/libstdc++.so.6.0.14
0071c000-00723000 rw-p 00000000 00:00 0 
00909000-0092d000 r-xp 00000000 08:01 8781918    /lib/libm-2.12.1.so
0092d000-0092e000 r--p 00023000 08:01 8781918    /lib/libm-2.12.1.so
0092e000-0092f000 rw-p 00024000 08:01 8781918    /lib/libm-2.12.1.so
00fdb000-00ff5000 r-xp 00000000 08:01 8781903    /lib/libgcc_s.so.1
00ff5000-00ff6000 r--p 00019000 08:01 8781903    /lib/libgcc_s.so.1
00ff6000-00ff7000 rw-p 0001a000 08:01 8781903    /lib/libgcc_s.so.1
08048000-0804b000 r-xp 00000000 08:01 8652645    /home/akg/Desktop/contest/a.out
0804b000-0804c000 r--p 00002000 08:01 8652645    /home/akg/Desktop/contest/a.out
0804c000-0804d000 rw-p 00003000 08:01 8652645    /home/akg/Desktop/contest/a.out
09f93000-09fb4000 rw-p 00000000 00:00 0          [heap]
b7600000-b7621000 rw-p 00000000 00:00 0 
b7621000-b7700000 ---p 00000000 00:00 0 
b7765000-b7768000 rw-p 00000000 00:00 0 
b7775000-b7779000 rw-p 00000000 00:00 0 
bf9a7000-bf9c8000 rw-p 00000000 00:00 0          [stack]
Aborted

What does this mean? How can i get rid of it? I'm not using malloc or free , I'm just using vector!

解决方案

Even if you're not allocating memory directly, it happens under the hood in vector code and you most likely corrupted some portion of memory by writing where you are not supposed to. The most likely reasons I can think of are:

  1. Writing to an element that is out of bounds
  2. Using a pointer/reference to an element that is no longer valid -- note that inserting more elements can invalidate earlier references

Of course, I can't say for sure unless you post some relevant code. Or try using valgrind to find the source of the problem.

这篇关于我收到此错误:“检测到 glibc"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:我收到此错误:“检测到 glibc"

基础教程推荐