?
Solved

Where is my core dump file in Ubuntu?

Posted on 2014-11-23
12
Medium Priority
?
488 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
LVL 38

Accepted Solution

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

Assisted Solution

by:Duncan Roe
Duncan Roe earned 1000 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 35

Expert Comment

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

Featured Post

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

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

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 show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Suggested Courses
Course of the Month9 days, 2 hours left to enroll

764 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