Re: [Rd] R windows crash (PR#9426)

From: <P.Dalgaard_at_biostat.ku.dk>
Date: Thu 21 Dec 2006 - 11:32:21 GMT


Prof Brian Ripley wrote:
> On Thu, 21 Dec 2006, Peter Dalgaard wrote:
>
> [...]
>
>
>> This seems reproducible on Linux, except that it goes into an infinite
>> loop. The lm call seems to be the real culprit:
>>
>>
>>> testfun <- function(aa=aa) return(aa)
>>> testfun()
>>>
>> Error in testfun() : recursive default argument reference
>>
>>> testfun <- function(aa=aa) lm(x~y,data=aa)
>>> testfun()
>>>
>> (*poof*)
>>
>
> The difference is in argument evaluation between closures and internal
> functions (c() in my example, return() in yours).
>
Er? I'd rather say that the issue is in the semantics of missing():

> f <- function(x) missing(x)
> testfun <- function(aa=aa) f(aa)
> testfun()


Error: segfault from C stack overflow

which is a bit nasty. AFAICS the thing is that the logic for detection of recursive arguments works by forcing promises (if you at some point need the result of the same promise you are forcing, you know that something is wrong), but missing() tries hard not to force promises. We already have the following anomaly,

> g <- function(v) missing(v)
> f <- function(v) g(v)
> f()


[1] TRUE
> f <- function(v=!h, h=!v) g(v)
> f()


[1] FALSE
> f <- function(v=!h, h) g(v)
> f()

[1] FALSE so the fix could be to realize that we cannot detect missingness in a perfectly reliable way and just pretend that arguments are always non-missing when they have a default.

[r-bugs reinserted as cc:]

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Dec 22 08:00:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Dec 2006 - 02:31:02 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.