From ripley at stats.ox.ac.uk  Mon Apr 23 19:20:04 2007
From: ripley at stats.ox.ac.uk (ripley at stats.ox.ac.uk)
Date: Mon, 23 Apr 2007 19:20:04 +0200 (CEST)
Subject: [Rd] plot.xy() with type="s" and huge data (PR#9629)
Message-ID: <20070423172004.0F89D5DE3C@slim.kubism.ku.dk>

On Mon, 23 Apr 2007, Bill Dunlap wrote:

> On Mon, 23 Apr 2007 ligges at statistik.uni-dortmund.de wrote:
>
>> The following code snippet crashes R (under Windows and Linux) for both
>> R-2.4.1 and R-2.5.0 RC as of yesterday:
>>
>>    set.seed(1)
>>    H <- rnorm(400000)
>>    temp <- rnorm(400000)
>>    plot(H, temp, type='s')
>>    # (no, it was not my idea to do something like that!)
>>
>>
>> I *guess* it is some overflow in plot.xy() which calls
>>    .Internal(plot.xy(xy, type, pch, lty, col, bg, cex, lwd, ...))
>> but I haven't investigated closely enough, submitting the bug report in
>> case anybody can (and has time to) fix this before tomorrow.
>
> It happens right after 2 calls to alloca(), which probably
> ought to be changed to non-stack allocations.  (On Linux there
> is a complaint about stack overflow and valgrind complains
> that someone changed the stack pointer.)  type='S' also uses
> alloca().

I think rather it should use alloca for moderate sizes (for speed), and 
something else for large ones.  Or perhaps we should just not allow such 
usage (the graphics device is going to have indigestion: Windows GDI only 
copes with 1000 segments or so and we need to split up the call).

Certainly not something to be fixed for 2.5.0, and pretty low priority.
What we can do quickly is stick in a stack check, which will stop the 
crash.

-- 
Brian D. Ripley,                  ripley at 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



[Rd] plot.xy() with type="s" and huge data (PR#9629)
ripley at stats.ox.ac.uk