Skip to content

core dump involving function closure (PR#402)

2 messages · Jim Lindsey, Peter Dalgaard

#
A user has crashed R90.1 on MS Windows by succesive calls to two of my
formula/function interpretors in an order that I had not foreseen. I
have checked and this also occurs with Intel RH5.2. I have distilled
the problem down to its bare bones as the following set of
instructions:

func <- function(.mu){
	.ch1 <- deparse(.mu,width=500)[-1]
	.fn <- eval(parse(text=paste("function()",
		paste("eval(attr(.fn,\"model\"))"))))
	attr(.fn,"model") <- parse(text=.ch1)
	.fn}

mu <- function() eval(attr(.fn,"model"))
func(mu)()

debug does not help much. It looks like an infinite loop to me but
that is no excuse for a crash. I have modified my functions so that it
can now only occur in one very improbable case. Jim

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
jlindsey@alpha.luc.ac.be writes:
Ouch. This kind of crash happens when the C stack grows too big and
you can no longer access automatic variables created on it. That's
pretty darn hard to avoid unless we want to put in some kind of
maxdepth check in the evaluator (which I suppose we could do).