Solved

Where is my core dump file in Ubuntu?

Posted on 2014-11-23
12
442 Views
Last Modified: 2015-05-28
Hello experts,

  I have a basic buffer overflow program as defined below, and I was trying to get a core dump from gdb.  Now, ulimit -c is unlimited (I've also set to 999999999, doesn't matter) and my core dump is nowhere to be found.  Any ideas why I can't create a dump?

user@user-VirtualBox:~/c_projects$ cat buff.c
#include <stdio.h>
#include <string.h>
int main(){
  printf("Enter the password:\n");
  char passw[15];
  int access;
  gets(passw);
  printf("You entered %s", passw);
  if(strcmp(passw, "password")){
        printf("Incorrect password!\n");
      access = 0;
  }
  else{
      printf("Correct password!\n");
      access = 1;
  }
  if(access){
      printf("access = %i\n", access);
      printf("You have access!\n");
  }
  return 0;
}


user@user-VirtualBox:~/c_projects$ gdb buff
(gdb) break 8
Breakpoint 1 at 0x4006aa: file buff.c, line 8.
(gdb) run
Starting program: /home/user/c_projects/buff
Enter the password:
password

Breakpoint 1, main () at buff.c:8
8        printf("You entered %s", passw);
(gdb) call abort()

Program received signal SIGABRT, Aborted.
0x00007ffff7a4af79 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(__GI_abort) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) quit
A debugging session is active.

      Inferior 1 [process 3489] will be killed.

Quit anyway? (y or n) y
user@user-VirtualBox:~/c_projects$ sudo find / -iname core -type f -mtime -1  /*No results!*/
user@user-VirtualBox:~/c_projects$ ulimit -c
unlimited
0
Comment
Question by:dilligent
  • 4
  • 2
  • 2
  • +1
12 Comments
 
LVL 19

Expert Comment

by:jools
ID: 40461633
Are you just trying to get gdb to create a core dump?

Last time I had a go at this was for a support thing, not sure if this is applicable but I used "generate-core-file" after being told how to set break points (I've no idea how to do break points as I was being talked thru it at the time).
0
 

Author Comment

by:dilligent
ID: 40461924
Yes, I was trying to get gdb to generate a core dump out of curiosity.
0
 
LVL 19

Expert Comment

by:jools
ID: 40462039
ok, well I'm not sure if the generate-core-file will work, it was some time ago I used it but I'm sure it was run from the gdb prompt.

You may well need to set a break point but I was just following instructions over the phone at the time so the man pages might be a good bet for helping with that, or you could rope in some programming topic groups that might have more current knowledge.
0
 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 250 total points
ID: 40463110
To create a core file:
gdb buff
catch signal SIGKILL
run

Open in new window


Then from another session, locate your buff application using ps, kill that process using kill <pid>

Watch debugger as it catches the kill signal, then:
gcore buff.core

Open in new window


You can add a path to your buff.core file like /tmp/buff.core

Use run or quit to continue or quit gdb
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:dilligent
ID: 40463183
So, what we're saying is that my book is wrong (or outdated)?  I can't dump the way I have defined?
0
 
LVL 19

Expert Comment

by:jools
ID: 40463254
book?

more likely the latter, software changes, I used it a while ago but fortunately had someone on the phone that knew how to use it, I just noted down the command to create the core dump (I might have needed "_" instead of "-") .

However, I'd go with Gerwin Jansens' response, he sounds like he has done it before :-)
0
 
LVL 19

Expert Comment

by:jools
ID: 40463257
I just did a google, it seems the online docs are up to date... feel free to put the book away for a bit.

https://sourceware.org/gdb/onlinedocs/gdb/Core-File-Generation.html
0
 
LVL 34

Assisted Solution

by:Duncan Roe
Duncan Roe earned 250 total points
ID: 40469652
To get a core dump, at the gdb prompt enter signal SIGABRT to send the signal to the program directly. I tried it and got a core dump
08:04:39$ g++ ee010.cpp -o ee10 -g3
08:04:48$ gdb ee10
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-slackware-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/dunc/tests/ee10...done.
(gdb) b main
Breakpoint 1 at 0x804892a: file ee010.cpp, line 10.
(gdb) run
Starting program: /home/dunc/tests/ee10 

Breakpoint 1, main (argc=1, argv=0xbfffed84) at ee010.cpp:10
10        cout << "Hello World" << endl;
(gdb) n
Hello World
12        string dummy;
(gdb) signal SIGABRT
Continuing with signal SIGABRT.

Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
(gdb) q
08:07:26$ ls -Flt
total 10552
-rw-------  1 dunc users   1998848 Nov 28 08:07 core
-rwxr-xr-x  1 dunc users     82113 Nov 28 08:04 ee10*
...

Open in new window

0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 40497419
dilligent - are you well?
Have you tried my solution? With what result?
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Guacamole and browser performance 1 64
Removing DES and 3DES ciphers in linux RedHat 6.8 38 99
Debug VNC connection on CentOS7 server 22 67
linux installs 6 49
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now