473,597 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determine where my C program core dump on solaris

I want to find out where (which line) my C program core dump.
How to do that?
Is there a web site describing the procedure?

One approach is to use stack trace of the mdb debugger, but I does not
understand its output completely.

e.g. How to interpret the stack trace to find out which line inside the
coredump_func function of a test program caused the

core dump?

$ CC -g coredump_fn.c
$ a.out
hello
Segmentation Fault (core dumped)
$ mdb core
Loading modules: [ libc.so.1 ld.so.1 ]
::stack
libc.so.1`strle n+0x18(10c76, ffbffbc4, ffbff441, 7b, 0, 0)
libc.so.1`print f+0xd8(10c70, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280, 4)
__1cNcoredump_f unc6F_i_+0x20(6 , ff2e87dc, ff2e87fa, ff2e8368, ff2e4280,
6)
main+0x20(1, ffbffcbc, ffbffcc4, 20c00, ff3301c0, ff330200)
_start+0xb8(0, 0, 0, 0, 0, 0)
>

/* coredump_fn.c : C test program for core dump generation */

#include <stdio.h>

int coredump_func() {
char *ptr = 0;
ptr = (char *) 123;
printf("ptr %s\n", ptr);
return 0;
}

int main(int argc, char *argv[])
{
int i = 0;
double x;

printf("hello\n ");
coredump_func() ;
x = 1.0 / i;
printf("x %f\n", x);

return 0;
}

Aug 31 '06 #1
10 7426
wo********@yaho o.ca wrote:
I want to find out where (which line) my C program core dump.
How to do that?
Is there a web site describing the procedure?

One approach is to use stack trace of the mdb debugger, but I does not
understand its output completely.

e.g. How to interpret the stack trace to find out which line inside the
coredump_func function of a test program caused the

core dump?

$ CC -g coredump_fn.c
$ a.out
hello
Segmentation Fault (core dumped)
$ mdb core
Loading modules: [ libc.so.1 ld.so.1 ]
>::stack

libc.so.1`strle n+0x18(10c76, ffbffbc4, ffbff441, 7b, 0, 0)
libc.so.1`print f+0xd8(10c70, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280, 4)
__1cNcoredump_f unc6F_i_+0x20(6 , ff2e87dc, ff2e87fa, ff2e8368, ff2e4280,
6)
main+0x20(1, ffbffcbc, ffbffcc4, 20c00, ff3301c0, ff330200)
_start+0xb8(0, 0, 0, 0, 0, 0)
OT here, but isn't it obvious that you are passing crap to printf which
causes strlen to barf?

--
Ian Collins.
Aug 31 '06 #2
wo********@yaho o.ca wrote:

<snipped>
e.g. How to interpret the stack trace to find out which line inside the
coredump_func function of a test program caused the

core dump?

$ CC -g coredump_fn.c
$ a.out
hello
Segmentation Fault (core dumped)
$ mdb core
Loading modules: [ libc.so.1 ld.so.1 ]
>::stack

libc.so.1`strle n+0x18(10c76, ffbffbc4, ffbff441, 7b, 0, 0)
libc.so.1`print f+0xd8(10c70, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280, 4)
__1cNcoredump_f unc6F_i_+0x20(6 , ff2e87dc, ff2e87fa, ff2e8368, ff2e4280,
6)
main+0x20(1, ffbffcbc, ffbffcc4, 20c00, ff3301c0, ff330200)
_start+0xb8(0, 0, 0, 0, 0, 0)
<ot>
I would guess that the stack trace above is
simply means main calls printf which calls strlen.

So, in main(), look for a printf call which uses
a %s format specifier. The string for that %s is
missing, munged, or simply NULL.

</ot>

You'll get more reliable information if you post
to a group where this is on-topic.

<snipped>

--
Have I offended you? Send flames to root@localhost
real email: lelanthran at gmail dot com
website : www.lelanthran.com
Aug 31 '06 #3
My goal is to find a general method to determine where a (long) C
program core dump.
Therefore I intentionally create a very short test program which will
core dump, then evaluate how good is the general method.
Here I try "mdb core" as the general method, which may or may not be
the best method.

Ian Collins wrote:
wo********@yaho o.ca wrote:
I want to find out where (which line) my C program core dump.
How to do that?
Is there a web site describing the procedure?

One approach is to use stack trace of the mdb debugger, but I does not
understand its output completely.

e.g. How to interpret the stack trace to find out which line inside the
coredump_func function of a test program caused the

core dump?

$ CC -g coredump_fn.c
$ a.out
hello
Segmentation Fault (core dumped)
$ mdb core
Loading modules: [ libc.so.1 ld.so.1 ]
::stack
libc.so.1`strle n+0x18(10c76, ffbffbc4, ffbff441, 7b, 0, 0)
libc.so.1`print f+0xd8(10c70, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280, 4)
__1cNcoredump_f unc6F_i_+0x20(6 , ff2e87dc, ff2e87fa, ff2e8368, ff2e4280,
6)
main+0x20(1, ffbffcbc, ffbffcc4, 20c00, ff3301c0, ff330200)
_start+0xb8(0, 0, 0, 0, 0, 0)
OT here, but isn't it obvious that you are passing crap to printf which
causes strlen to barf?

--
Ian Collins.
Aug 31 '06 #4
goose wrote:

<ot>
I would guess that the stack trace above is
simply means main calls printf which calls strlen.
I gathered that the OP knows this quite well, and had contrived the
example to illustrate his question, which is about analyzing core dumps
using a particular debugger.

I tend to use truss or strace to find out where such things are failing,
because it's a lot easier to do that than to mess with the debugger.

</ot>
Aug 31 '06 #5
Ian Collins wrote:
OT here, but isn't it obvious that you are passing crap to printf which
causes strlen to barf?

The OP cooked up the example in order to make it obvious. He's not
asking why the program crashes, he's asking how to analyze that kind of
crash in the debugger.
Aug 31 '06 #6
wo********@yaho o.ca wrote:
<fixed top-posting>
Ian Collins wrote:
<snipped>
>>OT here, but isn't it obvious that you are passing crap to printf which
causes strlen to barf?
a) As Ian Collins pointed out, this is off-topic.
b) Don't top-post.
--
Have I offended you? Send flames to root@localhost
real email: lelanthran at gmail dot com
website : www.lelanthran.com
Aug 31 '06 #7
wo********@yaho o.ca wrote:

Please don't top post, see <http://www.caliburn.nl/topposting.html >.
Ian Collins wrote:
>>wo********@ya hoo.ca wrote:
>>>I want to find out where (which line) my C program core dump.
How to do that?
Is there a web site describing the procedure?

One approach is to use stack trace of the mdb debugger, but I does not
understand its output completely.

e.g. How to interpret the stack trace to find out which line inside the
coredump_fun c function of a test program caused the

core dump?

$ CC -g coredump_fn.c
$ a.out
hello
Segmentati on Fault (core dumped)
$ mdb core
Loading modules: [ libc.so.1 ld.so.1 ]
::stack

libc.so.1`st rlen+0x18(10c76 , ffbffbc4, ffbff441, 7b, 0, 0)
libc.so.1`pr intf+0xd8(10c70 , ff2e87dc, ff2e87fa, ff2e8368, ff2e4280, 4)
__1cNcoredum p_func6F_i_+0x2 0(6, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280,
6)
main+0x20( 1, ffbffcbc, ffbffcc4, 20c00, ff3301c0, ff330200)
_start+0xb8( 0, 0, 0, 0, 0, 0)

OT here, but isn't it obvious that you are passing crap to printf which
causes strlen to barf?
My goal is to find a general method to determine where a (long) C
program core dump.
Therefore I intentionally create a very short test program which will
core dump, then evaluate how good is the general method.
Here I try "mdb core" as the general method, which may or may not be
the best method.
What ever you do will be system and tool specific.

Pick a tool, understand its output and maybe write an script of program
to parse the output if you wish to simplify it.

--
Ian Collins.
Aug 31 '06 #8
wo********@yaho o.ca wrote:
My goal is to find a general method to determine where a (long) C
program core dump.
man truss

Followup-to: comp.unix.solar is

Please don't top-post there either.
Aug 31 '06 #9
jmcgill wrote:
goose wrote:

<ot>
>>I would guess that the stack trace above is
simply means main calls printf which calls strlen.


I gathered that the OP knows this quite well, and had contrived the
example to illustrate his question, which is about analyzing core dumps
using a particular debugger.
And I very tersely(sp?) showed him how to do this
without even looking at the source. I explained what
the (now snipped) stack trace *means*. That is what
was requested, AIUI?
I tend to use truss or strace to find out where such things are failing,
because it's a lot easier to do that than to mess with the debugger.
Oh, I don't know about that; on the rare occassion that
my program crashes, I simply look at the stack trace
left behind in the core file (gdb loads corefiles). I've
not yet *really* needed to step through a debugger,
although I have used them in the embedded space.
</ot>

--
Have I offended you? Send flames to root@localhost
real email: lelanthran at gmail dot com
website : www.lelanthran.com
Aug 31 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2094
by: Dave Harrison | last post by:
Hi all, got a problem combinging mx and MySQLdb, when I build and install both for my Python2.1 install on a Solaris 9 box I can import mx fine, but importing MySQLdb causing python to core dump. I am using egenenix 2.0.4 and MySQLdb 0.9.2. I have also replaced the -shared flag in the Makefile is /usr/local/lib/Python2.1/config with -G (a recommended solaris change to let the build of the modules work in the first place) -> notably I also...
5
4941
by: Ganesh Gella | last post by:
Hi All, I am using g++ on Linux, and my code has lot of vectors each stores a particualr type of structure. (Structure internally had some vectors). When I am trying to push_back an element to a one of the vectors in the parent strutcure, it always core dumps on Linux and HP. On Solaris the same code is working fine without any problem. My code is actually an API, and this problem is seen only by few
2
3735
by: Johan den Boer | last post by:
Hi I tried the code below ( parseDoc ) on my xml file ( see below ) but this gives me a core dump on xmlStrcmp function. It seems that cur->name is a NULL pointer. cur->contents has the value 'story'. What am I doing wrong ? xml file
1
3493
by: Martin | last post by:
I use dbx and i got the following error: Reading GL_CliConnMgr core file header read successfully Reading ld.so.1 dbx: core file read error: address 0xff3e6000 not available dbx: core file read error: address 0xff3e70a0 not available dbx: warning: could not initialize librtld_db.so.1 -- trying libDP_rtld_db.so Make sure this is the same version of Solaris where the core dump
0
1226
by: Gumby | last post by:
Is gprof on Solaris 9 X86 not as supported as Solaris 9 Sparc? At work when we try to compile a program with -pg to use gprof to performance profile our software, the compiled app just dies instantly when it's started, no gmon.out file is made and the core file can't be traced by ddd: (it warns there's no symbols or no stack something like that). We did remove /usr/lib from the LD_LIBRARY_PATH and substituted it with /usr/lib/libp as...
1
4593
by: Martin | last post by:
Hi, I am developing a "huge" and portable software which works fine on windows in Release/Debug Mode and on Unix in Debug Mode but crashes when it "new" an object(GL_V5_CCM_RQRealTime_Rpy* msgBody = new GL_V5_CCM_RQRealTime_Rpy;) in Release Mode. I got a core and i used dbx to back trace to "_malloc_unlocked". I have used purify(Windows) to check if there is anything wrong and i also use "_heapchk()" in windows and everything goes fine....
21
3568
by: Joakim Hove | last post by:
Hello, I have implemented a small library with a function a datatype to manage temporary storage, and handle out correctly casted storage. The function to get a double pointer is for instance: double * work_get_double(work_type *work, size_t size) {} Now, if the work area is not sufficiently large, the function fails,
5
2178
by: Melissa Evans | last post by:
Hi. I'm new to Python. :) I've modified grappy.py, http://www.stacken.kth.se/~mattiasa/projects/grappy/, a postfix policy daemon for greylisting. to use LDAP as a backend instead of SQL (with python-ldap.) The daemon runs fine when testing but when I put it under load it core dumps quickly. What little analysis I know how to do shows similar information every time. Any advice on where to go from here? Thanks!
1
2384
by: gquiring | last post by:
I get a core dump while trying make install for PHP 5.2.4. Solaris 9 (Sparc), gcc 3.4.6. Configure options: ../buildconf --force ../configure '--enable-pdo' '--with-pdo-informix=/u/informix' '--with- apxs2=/usr/local/apache/bin/apxs' '--with-config-file-path=/etc' '-- enable-ftp' '--with-gettext' '--enable-force-cgi-redirect' '--enable- pic' '--enable-inline-optimization' '--with-ncurses' '--with-iconv' '--
0
7971
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8259
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6698
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3889
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2408
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1243
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.