Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite recursion after grouped objects are returned unlocked #4173

Closed
mllg opened this issue Jan 13, 2020 · 1 comment · Fixed by #4183
Closed

Infinite recursion after grouped objects are returned unlocked #4173

mllg opened this issue Jan 13, 2020 · 1 comment · Fixed by #4183
Labels
Milestone

Comments

@mllg
Copy link
Contributor

@mllg mllg commented Jan 13, 2020

11ab05a introduced an infinite recursion:

  # from the commit:
  runlock = function(x) {
    if (is.recursive(x)) {
      if (inherits(x, 'data.table')) .Call(C_unlock, x)
      else return(lapply(x, runlock))
    }
    return(invisible())
  }

# example input data
x = new.env()
x$a = 2
x$b = x

runlock(x)

Background: we are creating R6 objects (basically environments) from grouped subsets of the data. Some of these objects have references to each other (c.f. https://github.com/mlr-org/mlr3/blob/master/R/BenchmarkResult.R#L226).

@mllg
Copy link
Contributor Author

@mllg mllg commented Jan 13, 2020

Here is another example more suited for unit tests:

f = function(data) {
  x = new.env()
  x$a = 2
  x$b = x
  x
}

dt = data.table(x = rep(1:3, each = 3), y = runif(9))
dt[, list(evaluated = list(f(copy(.SD)))), by = x]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants