l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
December 2: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2003 Mar 21 14:46

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] malloc() is ... old school?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] malloc() is ... old school?



On Fri, Mar 21, 2003 at 01:01:39PM -0800, Jeff Newmiller wrote:

> > >
> > > And I submit that without the core dump, the bug of having forgotten
> > > to set *person's fields just got much, much harder to track down.
> > >
> > 
> > Core dumps are useful for tracking down bugs.
> 
> While I am not very comfortable with bunches of NULL pointers in records, 
> I am not sure that depending on the garbage in a malloc'd memory block to
> be non-NULL is a good idea either.

No, it's not. But it is at least a good deal more likely to be
non-NULL.

But you're right: a more reliable way to ensure core dumps when you
make an error of this sort is to *specifically* initialize all values
to something you *know* will dump core. I've heard from people that do
this.

Of course, this really doesn't get you anywhere, since you could
forget to initialize your pointers to garbage just as easily as you
can forget to initialize them to something more meaningful. And
linking with electric fence will get you about the same level of
reliability, with much less work.

Turning on -W -Wall -O2 and not ignoring the resulting warnings can be
very helpful for detecting initialization problems, too. But I still
prefer the direct, blunt forcefulness that a core dump presents... :-)

-Micah
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!