From murdoch.duncan at gmail.com  Fri Apr 23 16:17:32 2010
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Fri, 23 Apr 2010 10:17:32 -0400
Subject: [Rd] segfault with format.POSIXct()
In-Reply-To: <A2E661EF-ACF5-42AF-8ED8-35C5710CF8FA@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>
Message-ID: <4BD1ABFC.5030101@gmail.com>

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.

Duncan Murdoch



[Rd] segfault with format.POSIXct()
Duncan Murdoch