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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 28 Apr 2006 - 08:39:06 GMT

On Wed, 26 Apr 2006, Prof Brian Ripley wrote:

> I think this is a C stack overflow problem. Probably needs a test added
> internally to save().

I've added such a test and it is now caught. (You still cannot actually save such an object.)

> I could not reproduce this on Linux: I got a C stack overflow that was
> caught.

Since Linux signals stack overflows and Windows does not.

>
>
> On Wed, 26 Apr 2006, Henrik Bengtsson (max 7Mb) wrote:
>
>> 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
>>
>>
>
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Apr 28 18:41:32 2006

This archive was generated by hypermail 2.1.8 : Fri 28 Apr 2006 - 10:17:45 GMT