From pdalgd at gmail.com  Fri Apr 23 16:36:02 2010
From: pdalgd at gmail.com (peter dalgaard)
Date: Fri, 23 Apr 2010 16:36:02 +0200
Subject: [Rd] segfault with format.POSIXct()
In-Reply-To: <4BD1ABFC.5030101@gmail.com>
References: <87r5m783mh.fsf@kolob.sebmags.homelinux.org>	<4BD18502.7020505@statistik.tu-dortmund.de>	<87vdbi72pc.fsf@kolob.sebmags.homelinux.org>
	<A2E661EF-ACF5-42AF-8ED8-35C5710CF8FA@gmail.com>
	<4BD1ABFC.5030101@gmail.com>
Message-ID: <04A1D6AB-6788-4E88-B413-2C122635C3F3@gmail.com>


On Apr 23, 2010, at 4:17 PM, Duncan Murdoch wrote:

> On 23/04/2010 10:03 AM, peter dalgaard wrote:
>> On Apr 23, 2010, at 2:50 PM, Sebastian P. Luque wrote:
>> 
>> > On Fri, 23 Apr 2010 13:31:14 +0200,
>> > Uwe Ligges <ligges at statistik.tu-dortmund.de> wrote:
>> > >> Works for me, both under Windows (32 and 64 bit) and Linux, although I
>> >> have not package slmisc attached.
>> > > Is this with 2.11.0 ?  Thanks.
>> 
>> I'm getting a bit further with bug 14267:
>> 
>> On OSX I am NOT seeing it with R-devel, although it is there with 2.11.0 Patched.
>> 
>> Running with a non-optimized compile, I can get some more information
>> 
>> It is happening on the i-th iteration of the loop in do_formatPOSIXlt with 
>> (gdb) p i
>> $4 = 86870
>> 
>> Unfortunately, it looks like a bigger exercise to get valgrind running on Snow Leopard -- too big for Friday afternoon anyway. However, the alloca() call on line 774 of src/main/datetime.c does look suspect to me. I can see that it was introduced with r51353 and has since disappeared in R-devel (r51398).
> 
> I've just committed a patch for this on R-2-11-branch.  The problem was that the alloca() was within a loop, so it kept allocating more and more space until the end of the function call, and blew the stack. In R-devel, this was changed to the C99 construct of defining a variable sized array within a block, and that was fine, because it was released at the end of the block, not at the end of the function call.

Yes, that's what I suspected. Thanks for the fix!

-p

> Duncan Murdoch

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] segfault with format.POSIXct()
peter dalgaard