[Rd] Large number of linked environments makes save() crash R

From: Henrik Bengtsson (max 7Mb) <hb_at_stat.berkeley.edu>
Date: Wed 26 Apr 2006 - 17:35:44 GMT


Hi,

first, this not a problem originating from me, but it was observed trying to do similar things with my R.oo package, so I troubleshooted it and found the following.

On R v2.3.0 (patched), the following will crash R on WinXP sooner or later:

troubleLimit <- 20435;

linkedList <- list(head=new.env());

currEnv <- linkedList$head;
for (kk in 1:(2*troubleLimit)) {
  if (kk %% 100 == 0)
    print(kk);
  nextEnv <- new.env();
  assign("nxt", nextEnv, envir=currEnv);   currEnv <- nextEnv;
  if (kk > troubleLimit) {
    cat("Saving linked list of length ", kk, "...", sep="");     save(linkedList, file="linkedList.RData");     cat("ok\n");
  }
}

This gives:
...
[1] 20300
[1] 20400

Saving linked list of length 20436...ok
Saving linked list of length 20437...ok
Saving linked list of length 20438...

and then R crashes/terminates. On my WinXP machine it always happens at the same number of environments.

I tried the same on R v2.2.0 (sic!) on Unix and there it gave a segfault a bit after 10000 environments. ...and, the purpose of the example is not to implement linked lists, it to show that you can torture R to crash.

Cheers

Henrik



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Apr 27 03:37:50 2006

This archive was generated by hypermail 2.1.8 : Wed 26 Apr 2006 - 20:17:55 GMT