C语言 需要有关中止(核心转储)的更多信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20242711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 10:24:08  来源:igfitidea点击:

Need more information about Aborted (core dumped)

cmallocruntime-errorcoredumpbacktrace

提问by gangadhars

This bellow code will generate Aborted (core dumped) at last line.

此波纹管代码将在最后一行生成中止(核心转储)。

code:

代码:

  #include <stdio.h>
  #include <malloc.h>

  int main()
  {
    char *ptr;
    ptr=malloc(sizeof(char)*10);
    free(ptr);
    free(ptr);     // core dumped
  }

output is:

输出是:

*** glibc detected *** ./a.out: double free or corruption (fasttop): 0x091f7008 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb7665ee2]
./a.out[0x804846d]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb76094d3]
./a.out[0x8048371]
======= Memory map: ========
08048000-08049000 r-xp 00000000 fc:00 4070236    /home/gangadhar/a.out
08049000-0804a000 r--p 00000000 fc:00 4070236    /home/gangadhar/a.out
0804a000-0804b000 rw-p 00001000 fc:00 4070236    /home/gangadhar/a.out
091f7000-09218000 rw-p 00000000 00:00 0          [heap]
b75ba000-b75d6000 r-xp 00000000 fc:00 22938319   /lib/i386-linux-gnu/libgcc_s.so.1
b75d6000-b75d7000 r--p 0001b000 fc:00 22938319   /lib/i386-linux-gnu/libgcc_s.so.1
b75d7000-b75d8000 rw-p 0001c000 fc:00 22938319   /lib/i386-linux-gnu/libgcc_s.so.1
b75ef000-b75f0000 rw-p 00000000 00:00 0 
b75f0000-b7794000 r-xp 00000000 fc:00 22937623   /lib/i386-linux-gnu/libc-2.15.so
b7794000-b7795000 ---p 001a4000 fc:00 22937623   /lib/i386-linux-gnu/libc-2.15.so
b7795000-b7797000 r--p 001a4000 fc:00 22937623   /lib/i386-linux-gnu/libc-2.15.so
b7797000-b7798000 rw-p 001a6000 fc:00 22937623   /lib/i386-linux-gnu/libc-2.15.so
b7798000-b779b000 rw-p 00000000 00:00 0 
b77b1000-b77b4000 rw-p 00000000 00:00 0 
b77b4000-b77b5000 r-xp 00000000 00:00 0          [vdso]
b77b5000-b77d5000 r-xp 00000000 fc:00 22937715   /lib/i386-linux-gnu/ld-2.15.so
b77d5000-b77d6000 r--p 0001f000 fc:00 22937715   /lib/i386-linux-gnu/ld-2.15.so
b77d6000-b77d7000 rw-p 00020000 fc:00 22937715   /lib/i386-linux-gnu/ld-2.15.so
bf7e0000-bf801000 rw-p 00000000 00:00 0          [stack]
Aborted (core dumped)

Here I'm interested to know in which cases these core dumped will occur?

在这里我很想知道这些核心转储会在哪些情况下发生?

Can we find out at which line this is occurred without using debugger?

我们可以在不使用调试器的情况下找出发生在哪一行吗?

what information it is showing(about shared libraries)?

它显示什么信息(关于共享库)?

回答by Chinna

Core dump file generally gets created when a program terminates abnormally. Calling free()twice on a pointer causes segmentation fault. That's why you are getting coredumped. You can find some information hereabout calling free on same pointer twice.

核心转储文件通常在程序异常终止时创建。free()对指针调用两次会导致分段错误。这就是你被核心转储的原因。你可以在这里找到一些关于在同一个指针上调用 free 两次的信息。