0

About a week ago I started having troubles getting a decent backtrace from a core dump using GDB. If I load the program in GDB and have it crash, I can get a backtrace fine.

This is what I get when doing it from a core dump:

(gdb) bt
#0  0x00007fd10ad42425 in ?? ()
#1  0x00007fd10ad45b8b in ?? ()
#2  0x0000000000000004 in ?? ()
#3  0x0000000000000005 in ?? ()
#4  0x00007ffff770887e in ?? ()
#5  0x0000000000000009 in ?? ()
#6  0x00007fd10ae87ea7 in ?? ()
#7  0x0000000000000003 in ?? ()
#8  0x00007ffff77072ba in ?? ()
#9  0x0000000000000006 in ?? ()
#10 0x00007fd10ae87eab in ?? ()
#11 0x0000000000000002 in ?? ()
#12 0x00007ffff77072ce in ?? ()
#13 0x0000000000000002 in ?? ()
#14 0x00007fd10ae85b82 in ?? ()
#15 0x0000000000000001 in ?? ()
#16 0x00007fd10ae87ea7 in ?? ()
#17 0x0000000000000003 in ?? ()
#18 0x00007ffff77072b4 in ?? ()
#19 0x000000000000000c in ?? ()
#20 0x00007fd10ae87eab in ?? ()
#21 0x0000000000000002 in ?? ()
#22 0x0000000000000020 in ?? ()
#23 0x0000000000000000 in ?? ()
(gdb) 

This happens regardless of whether it's a SIGSEGV, SIGABRT (Unhandled exception or assert/verify).

I am compiling with the following compiler flags:

g++ -Wall -Wextra -g -ggdb -std=gnu++0x -rdynamic -pthread -O0

I can't really think of anything that has changed to be causing this. Any ideas?

goji
  • 6,911
  • 3
  • 42
  • 59
  • Why would you still be able to get a backtrace inside gdb (no core dump) then? Shouldn't a corrupt stack cause the same problem there? – goji Dec 05 '12 at 21:01
  • 1
    What's you gdb command line? To state the obvious, are you giving it the right executable...? – Nicholas Wilson Dec 05 '12 at 21:01
  • Damn. I just realised what the problem is. Old core file isn't being overwritten. I just presumed the core file was the current one. http://stackoverflow.com/questions/12666801/why-is-my-core-file-not-overwritten – goji Dec 05 '12 at 21:07

1 Answers1

2

Turns out that despite the "core dumped" message, if there was an older existing core file, it wasn't being overwritten. This is apparently a ubuntu bug according to this:

Why is my core file not overwritten?

Community
  • 1
  • 1
goji
  • 6,911
  • 3
  • 42
  • 59
  • 2
    In case you want to distingish between core files, the following might be handy: /sbin/sysctl -w "kernel.core_pattern=core.%e.%p". This will name core files like 'core.my_program.12345'. %e is het executable name, %p the process ID. – JvO Dec 05 '12 at 23:18
  • nice, this might prevent future confusion ;) – goji Dec 05 '12 at 23:38
  • JvO : That's nice, just to improvise further is there any way to add time stamp ? – Kamath Dec 06 '12 at 07:29
  • 1
    @Kamath Yes, just add "%t" in the pattern (same as "%e" or "%p"). – crollywood Feb 17 '17 at 13:40