Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > in what circustances perror would cause core dump?

Reply
Thread Tools

in what circustances perror would cause core dump?

 
 
Martin
Guest
Posts: n/a
 
      12-09-2004
My program cored and the following is the call stack in dbx. I would
like to know what are the possibilities that when perror is being
called, it will core?

dbx: warning: cannot get thread count -- generic libthread_db.so error
dbx: warning: thread related commands will not be available
dbx: warning: see `help lwp', `help lwps' and `help where'
(l@22) dbx: warning: cannot get thread count -- generic
libthread_db.so error
terminated by signal SEGV (no mapping at the fault address)
0xff111278: ferror+0x0028: ldub [%i0 + 0xe], %o0
(/opt/SUNWspro/bin/../WS6U2/bin/sparcv9/dbx) where
=>[1] ferror(0x0, 0x53683c, 0x53683c, 0xff13fdc8, 0xff1ea08c, 0x39),
at 0xff111278
[2] GL_MsgLogger::record(0xfbca30, 0x0, 0xfc8f1f98, 0x312, 0x1,
0xfc8f175d), at 0x380198
[3] GL_V5Session::Send(0xfc3a30, 0xfc8f85a0, 0x531628, 0xfbca30,
0xfc8f6008, 0xfc8f6010), at 0x34b0dc
 
Reply With Quote
 
 
 
 
Richard Bos
Guest
Posts: n/a
 
      12-09-2004
(Martin) wrote:

> My program cored and the following is the call stack in dbx. I would
> like to know what are the possibilities that when perror is being
> called, it will core?


There's no reason for perror() itself to dump core, so the only thing I
can imagine is that you made a mistake earlier on, either clobbering
over the allocation arena, or assigning a bogus value to errno; and that
this earlier error went unnoticed until it confused perror().

Richard
 
Reply With Quote
 
 
 
 
dandelion
Guest
Posts: n/a
 
      12-09-2004

"Richard Bos" <> wrote in message
news:...
> (Martin) wrote:
>
> > My program cored and the following is the call stack in dbx. I would
> > like to know what are the possibilities that when perror is being
> > called, it will core?

>
> There's no reason for perror() itself to dump core, so the only thing I
> can imagine is that you made a mistake earlier on, either clobbering
> over the allocation arena, or assigning a bogus value to errno; and that
> this earlier error went unnoticed until it confused perror().


Passing perror an invalid pointer would do the trick. Not bthat perror is to
blame for that, but *effectively* it's perror which causes the coredump by
dereferencing the faulty pointer. I agree, however, that the fault is not
perror().

So i'd advice to check wether the pointer which is passed to perror is
either valid or null.


 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      12-09-2004
"dandelion" <> wrote:

>
> "Richard Bos" <> wrote in message
> news:...
> > (Martin) wrote:
> >
> > > My program cored and the following is the call stack in dbx. I would
> > > like to know what are the possibilities that when perror is being
> > > called, it will core?

> >
> > There's no reason for perror() itself to dump core, so the only thing I
> > can imagine is that you made a mistake earlier on, either clobbering
> > over the allocation arena, or assigning a bogus value to errno; and that
> > this earlier error went unnoticed until it confused perror().

>
> Passing perror an invalid pointer would do the trick. Not bthat perror is to
> blame for that, but *effectively* it's perror which causes the coredump by
> dereferencing the faulty pointer. I agree, however, that the fault is not
> perror().


Erm... yes, of course. I was focusing on the error message, and
completely failed to look at the actual argument. Stupid.

Richard
 
Reply With Quote
 
dandelion
Guest
Posts: n/a
 
      12-09-2004

"Richard Bos" <> wrote in message
news:...
> "dandelion" <> wrote:
>
> >
> > "Richard Bos" <> wrote in message
> > news:...
> > > (Martin) wrote:
> > >
> > > > My program cored and the following is the call stack in dbx. I would
> > > > like to know what are the possibilities that when perror is being
> > > > called, it will core?
> > >
> > > There's no reason for perror() itself to dump core, so the only thing

I
> > > can imagine is that you made a mistake earlier on, either clobbering
> > > over the allocation arena, or assigning a bogus value to errno; and

that
> > > this earlier error went unnoticed until it confused perror().

> >
> > Passing perror an invalid pointer would do the trick. Not bthat perror

is to
> > blame for that, but *effectively* it's perror which causes the coredump

by
> > dereferencing the faulty pointer. I agree, however, that the fault is

not
> > perror().

>
> Erm... yes, of course. I was focusing on the error message, and
> completely failed to look at the actual argument. Stupid.


Considering all the times i've put my foot in my mouth, i would hardly call
it that.

Errare humanum est, after all.


 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      12-09-2004
On 8 Dec 2004 22:56:23 -0800, in comp.lang.c ,
(Martin) wrote:

>My program cored and the following is the call stack in dbx. I would
>like to know what are the possibilities that when perror is being
>called, it will core?


calling perror() with a null argument would seem to be UB, so that might
core.

You might also get a core if your stack were so horribly corrupted before
the perror call, that it was working with garbage. Suspect earlier
problems.


--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
kevin.bagust
Guest
Posts: n/a
 
      12-09-2004
In article <>,
Mark McIntyre <> wrote:
> On 8 Dec 2004 22:56:23 -0800, in comp.lang.c ,
> (Martin) wrote:


> >My program cored and the following is the call stack in dbx. I would
> >like to know what are the possibilities that when perror is being
> >called, it will core?


> calling perror() with a null argument would seem to be UB, so that might
> core.


No, calling perror() with a null argument is defined. From the standard
(7.19.10.4#2):

....first (if s is not a null pointer and the character pointed to by S is
not the null character), the string pointed to by s followed by a colon (
: ) ....

which suggests that s can be the null pointer.

Kevin Bagust.

 
Reply With Quote
 
Chris Torek
Guest
Posts: n/a
 
      12-09-2004
In article < >
Martin <> wrote:
>My program cored and the following is the call stack in dbx. I would
>like to know what are the possibilities that when perror is being
>called, it will core?


Calling perror() with an invalid argument could do that. What I
do not understand is why you are asking about perror() when the
text below suggests the code is calling ferror():

>terminated by signal SEGV (no mapping at the fault address)
>0xff111278: ferror+0x0028: ldub [%i0 + 0xe], %o0
>(/opt/SUNWspro/bin/../WS6U2/bin/sparcv9/dbx) where
>=>[1] ferror(0x0, 0x53683c, 0x53683c, 0xff13fdc8, 0xff1ea08c, 0x39),
>at 0xff111278
> [2] GL_MsgLogger::record(0xfbca30, 0x0, 0xfc8f1f98, 0x312, 0x1,
>0xfc8f175d), at 0x380198
> [3] GL_V5Session::Send(0xfc3a30, 0xfc8f85a0, 0x531628, 0xfbca30,
>0xfc8f6008, 0xfc8f6010), at 0x34b0dc


It is hard to be sure (because "optimization" can change things), but
given what I know about the specific machine, and this output from
the debugger, it looks like someone did:

ferror(fp)

where fp == NULL.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting 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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts Problem <!-- PError 500: Missing message for key button.submit nanda.rudraraju@gmail.com Java 0 04-07-2006 02:34 PM
Core Solo & Core Duo are not Core microarchitecture; 65nm Pentium M chips bigal Hardware 0 03-22-2006 11:24 AM
cout and perror puzzlecracker C++ 3 10-22-2005 11:56 PM
perror question Clunixchit C Programming 1 06-19-2005 01:44 AM
When to use "perror" and "fprintf" L. Westmeier C Programming 6 05-13-2004 07:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57