Solved

Where is my core dump file in Ubuntu?

Posted on 2014-11-23
12
461 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 38

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
php56-php-mcrypt for rhel7 php56 1 111
Loading flat file data in tables 2 65
Advice on ESXi 5.1 Health / Storage 1 48
CentOS Backup Options 3 18
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

730 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