[R] How do I track a segfault?

Aleksey Naumov naumov at acsu.buffalo.edu
Thu Dec 14 17:59:56 CET 2000

Dear R users,

I have to catch a nasty bug and would appreciate any advice or help!

I get a segfault (core dumped) that happens in one of my own functions.
The problem is, it
does not happen most of the time, only sometimes, so it's very hard to
reproduce. Or it may
run ok in interactive mode, but bug out in batch mode. Also, it tends to
happen more on
the slower of my 2 machines (PII 266), then I run it on the faster one
(PII 400) and it usually
works (but then bugs out there as well, at some other time)...

Once it starts to segfault, re-running my script typically doesn't help,
it does it over and over,
even though I start a new R process every time.

I found out that if I insert some cat()'s or print()'s in that function,
it typically goes through,
although I may have to insert several before it works, and it doesn't
help in every case. I don't
think sending in my function would be very helpful - it's actually
called from a few other functions,
and then again, it's not reproducable in any reliable way... (but I'll
be glad to send it if it's useful)
I've actually narrowed down where it happens in the function, looks like
it's at a call to sweep().
Of course, I can easily send the 'core' file...

The best thing for me would be some advice on how to track a problem
like this? What's the
best debugging tool and/or method I should use? Is there a tutorial on
debugging in R?
I read in FAQ that ESS is the way to go for debugging, but I am starting
to look at it , so it'll
be some time before I could do something intelligent. Would appreciate
any hints on how to
do debugging in it!

BTW, how do I use Up & Down keys for command history in XEmacs R mode? I
see in the
ESS buffer:

Making Process...Buf *R*, Proc R, Prog R
 Start File=nil, Args= --no-readline .

I guess I don't want --no-readline; how do I change it? (I have to admit
- having to use emacs
is no fun :-( so far)

Info that may help:
RedHat-6.2 on Intel (PII 266 and 400)
512M RAM
R 1.1.1 compiled from tar

Thank you


r-help 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-help-request at stat.math.ethz.ch

More information about the R-help mailing list