From andy_liaw@merck.com  Thu Jun 13 17:48:09 2002
From: andy_liaw@merck.com (Liaw, Andy)
Date: Thu, 13 Jun 2002 12:48:09 -0400
Subject: [R] help debugging segfaults
Message-ID: <51F9C42DA15CD311BD220008C707D81906FFC365@usrymx10.merck.com>

OK, so I linked my code against libefence and then run my test code under
gdb.  It still finishes without reporting any problem.  (This is with
Calloc() and Free(), instead of S_alloc().)  Can anyone tell me what to do
or look for next?  I'll be eternally grateful!

Regards,
Andy

> -----Original Message-----
> From: Thomas Lumley [mailto:tlumley@u.washington.edu]
> Sent: Thursday, June 13, 2002 12:05 PM
> To: Liaw, Andy
> Cc: 'r-devel@stat.math.ethz.ch'
> Subject: RE: [R] help debugging segfaults
> 
> 
> On Thu, 13 Jun 2002, Liaw, Andy wrote:
> >
> > Everyone suggested using some malloc debugger (such as 
> Electric Fence).  All
> > I did was following half of what BDR suggested below, i.e., 
> changing all the
> > S_alloc() calls to Calloc() and Free().  I didn't get to 
> try efence, and the
> > problem seems to have disappeared!
> 
> No, the *symptoms* have disappeared. This is not necessarily an
> improvement.
> 
> > As I read it from the R-exts manual, the difference between 
> S_alloc and
> > Calloc is that S_alloc takes memory from the heap, whereas 
> Calloc takes
> > memory addtional to the heap.  So can anyone explain what's 
> going on?  It's
> > still kind of mysterious to me...
> 
> It looked as if your code was writing to/reading from memory 
> that didn't
> belong to it. What happens then depends on who the memory 
> does belong to,
> and what they are doing with it. There's no guarantee that 
> just because it
> doesn't crash today that it won't in the future, or worse, 
> start giving
> subtly wrong answers.
> 
> A segmentation fault is a good thing in this context -- it's 
> a sign that
> the operating system has protected you from the consequences of your
> actions by killing the program.
> 
> 	-thomas
> 
> 

------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.

==============================================================================

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[R] help debugging segfaults
Liaw, Andy