Avatar of dilligent
dilligent
 asked on

Where is my core dump file in Ubuntu?

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
Linux DistributionsCLinux OS DevLinux

Avatar of undefined
Last Comment
Duncan Roe

8/22/2022 - Mon
Julian Parker

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).
dilligent

ASKER
Yes, I was trying to get gdb to generate a core dump out of curiosity.
Julian Parker

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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Gerwin Jansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dilligent

ASKER
So, what we're saying is that my book is wrong (or outdated)?  I can't dump the way I have defined?
Julian Parker

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 :-)
Julian Parker

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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Duncan Roe

dilligent - are you well?
Have you tried my solution? With what result?