Solved

Where is my core dump file in Ubuntu?

Posted on 2014-11-23
12
449 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 37

Accepted Solution

by:
Gerwin Jansen, EE MVE 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
 

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

803 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