[Rd] R windows crash (PR#9426)
Luke Tierney
luke at stat.uiowa.edu
Thu Dec 21 14:32:04 CET 2006
On Thu, 21 Dec 2006, P.Dalgaard at biostat.ku.dk wrote:
> 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.
We could also mark the promise created for default arguments so it can
be identified as such and use that info in missing(). Probably worth
deciding what the intended semantics are here and then figuring out
the implementation.
Best,
luke
--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa Phone: 319-335-3386
Department of Statistics and Fax: 319-335-3017
Actuarial Science
241 Schaeffer Hall email: luke at stat.uiowa.edu
Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
More information about the R-devel
mailing list