From josh.m.ulrich at gmail.com  Tue Dec  6 17:43:38 2016
From: josh.m.ulrich at gmail.com (Joshua Ulrich)
Date: Tue, 6 Dec 2016 10:43:38 -0600
Subject: [Rd] segfault with POSIXlt zone=NULL zone=""
In-Reply-To: <20161206163036.GB8476@ofb.net>
References: <20161206123720.GA21285@ofb.net>
	<CAPPM_gRX8zWeDk=jiL2=goqFhbcw12OCW0NXDbnCB9Er6hTdVA@mail.gmail.com>
	<20161206163036.GB8476@ofb.net>
Message-ID: <CAPPM_gQk3km4C9yPs_HzbDHdbyQg0WmxK-Bk=q1a99PVk27GqQ@mail.gmail.com>

On Tue, Dec 6, 2016 at 10:30 AM,  <frederik at ofb.net> wrote:
> Hi Joshua,
>
> Thank you for minimizing my test case.
>
>> > Hope I'm not doing something illegal...
>> >
>> You are.  You're changing the internal structure of a POSIXlt object
>> by re-ordering the list elements.  You should not expect a malformed
>> POSIXlt object to behave as if it's correctly formed.  You can see
>> it's malformed by comparing it's unclass()'d output.
>>
>> d <- as.POSIXlt(Sys.time())
>> unclass(d)  # valid POSIXlt object
>> d$zone <- NULL
>> d$zone <- ""
>> unclass(d)  # your malformed POSIXlt object
>
> I don't know if these questions are not already obvious, but:
>
> 1. Is there a reasonable way to fail more elegantly when a user makes
> this mistake?
>
It's not just "this mistake".  See below.

> 2. Should we update the documentation for POSIXlt to warn people that
> the optional "zone" list element must precede the optional "gmtoff"
> list element, in cases where both are present?
>
No, because that's not the only way to create a malformed POSIXlt
object. Reordering *any* of the elements results in a segfault, and
there are probably other things you could do to the internal structure
of POSIXlt objects to cause segfaults.

Maybe update the documentation to say, "If you update the internal
structure of a POSIXlt object, you deserve whatever happens."? ;-)

> Thanks,
>
> Frederick



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com



[Rd] segfault with POSIXlt zone=NULL zone=""
Joshua Ulrich