Re: [Rd] mget call can trigger C stack usage error

2016-09-08 Thread Gabriel Becker
Alexandre,

AFAICS, this code actually causes infinite recursion, and here's why:


   1. formals grabs returns the formals of the function identified by
   sys.function(sys.parent()) this ends up being print.new, whose first
   argument is x
   2. mget looks for the symbol x in envir = as.environment(-1L) which ends
   up being the evaluation frame for print.new [1]
   3. x in that environment resolves the the object you are trying to print
   4. print() is called on that object, and dispatches to print.new() ...



[1]

> debug(mget)

> foo

**

[1] "envir"  "ifnotfound" "inherits"   "mode"   "x"

Browse[2]> *envir*

**

Browse[2]> sys.frames()

[[1]]




*[[2]]*

**


**


Browse[2]> sys.calls()

[[1]]

function (x, ...)

UseMethod("print")(x)


*[[2]]*

*print.new(x)*


**


Browse[2]> class(envir$x)

[1] *"new"*

Hope that helps.
~G

On Mon, Sep 5, 2016 at 4:48 PM, Alexandre Courtiol <
alexandre.court...@gmail.com> wrote:

> Hi all, not sure if you will call this a bug or something else but the
> following silly call trigger a low level error:
>
> foo <- list(x=1)
> class(foo) <- "new"
> print.new <- function(x, ...) print(mget(names(formals(
> foo
>
> > Error: C stack usage  7969412 is too close to the limit
>
>
>
> --
> Alexandre Courtiol
>
> http://sites.google.com/site/alexandrecourtiol/home
>
> *"Science is the belief in the ignorance of experts"*, R. Feynman
>
> [[alternative HTML version deleted]]
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Gabriel Becker, PhD
Associate Scientist (Bioinformatics)
Genentech Research

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] mget call can trigger C stack usage error

2016-09-06 Thread Alexandre Courtiol
Hi all, not sure if you will call this a bug or something else but the
following silly call trigger a low level error:

foo <- list(x=1)
class(foo) <- "new"
print.new <- function(x, ...) print(mget(names(formals(
foo

> Error: C stack usage  7969412 is too close to the limit



-- 
Alexandre Courtiol

http://sites.google.com/site/alexandrecourtiol/home

*"Science is the belief in the ignorance of experts"*, R. Feynman

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel