Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How Can I Provoke a CORE Dump?

How Can I Provoke a CORE Dump?
Thread Tools
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Dec 3, 2002, 02:18 AM
 
I'm learning gdb and have one example that is supposed to core dump but instead I get a bus error and no core dump file to look at -bummer.

Below is the example that I'm using. It tries to set the 0x0 address which is illegal.


/* ---------------------------


char **nowhere;
void setbad();

int main(int argc, char *argv[])
{
setbad();
printf("%s\n", *nowhere);
}

void setbad(){
nowhere = 0;
*nowhere = "This is a string\n";
}


/* ---------------------------

So, it would be great if you folks can provide this newbie with some code that would actually generate a core dump file.

Thanks!
     
Professional Poster
Join Date: Sep 1999
Location: Ottawa, ON, Canada
Status: Offline
Reply With Quote
Dec 3, 2002, 08:20 AM
 
Try a random address instead of 0.
Or try reading a random address instead of writing to it.
     
Dedicated MacNNer
Join Date: May 2001
Status: Offline
Reply With Quote
Dec 4, 2002, 07:46 PM
 
Wouldn't just dividing by zero cause a core dump?

W
     
Fresh-Faced Recruit
Join Date: Feb 2002
Location: Lisbon, Portugal
Status: Offline
Reply With Quote
Dec 17, 2002, 10:34 AM
 
MacOS X doesn't dump cores by default. Here's what the 'limit' command reveals on the shell:

[dhcp249:~] jpp% limit
cputime unlimited
filesize unlimited
datasize 6144 kbytes
stacksize 512 kbytes
coredumpsize 0 kbytes
memoryuse unlimited
descriptors 256
memorylocked unlimited
maxproc 100
[dhcp249:~] jpp%

You must override that 0kb limit for coredumps. Type 'limit coredump 1000000' or with any other arbitrarily large number to enable core dumps. You can verify the change by running 'limit' without any arguments again. This change will only be valid for the currently running shell. Other shells will not be afected.
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Dec 18, 2002, 08:02 AM
 
You might finds this useful as well.
NAME
abort - cause abnormal program termination

LIBRARY
Standard C Library (libc, -lc)
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:25 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2