[Rd] Large number of linked environments makes save() crash R
Henrik Bengtsson (max 7Mb)
hb at stat.berkeley.edu
Wed Apr 26 19:35:44 CEST 2006
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
More information about the R-devel
mailing list