From spencer.graves at prodsyse.com  Tue Dec  6 18:51:10 2016
From: spencer.graves at prodsyse.com (Spencer Graves)
Date: Tue, 6 Dec 2016 11:51:10 -0600
Subject: [Rd] ok to segfault with POSIXlt zone=NULL zone=""?
In-Reply-To: <20161206172743.GC8476@ofb.net>
References: <20161206123720.GA21285@ofb.net> <20161206172743.GC8476@ofb.net>
Message-ID: <a300256e-7253-ecc8-8d68-193ce493aa68@prodsyse.com>

I got a similar result from R-Studio 1.0.44 with

 > sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X El Capitan 10.11.6

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils
[5] datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_3.3.2

 > d <- as.POSIXlt(Sys.time())
 > d$zone <- NULL
 > d$zone <- ""

:  "R Session Aborted.  R encountered a fatal error.  The session was 
terminated.  Start New Session".


       I got essentially the same result with R 3.3.1.  Then I installed 
3.3.2 and got the above.


       Spencer Graves


On 12/6/2016 11:27 AM, frederik at ofb.net wrote:
> Hi all,
>
> Here's a more minimal version of my earlier bug report (thanks, Joshua
> Ulrich):
>
> d=as.POSIXlt(Sys.time()); d$zone=NULL; d$zone=""; d
>
> I got some helpful, if glib, feedback from Joshua that the segfault
> may be caused by the changing of the order of the list elements in 'd'
> (representing the "internal structure" of the POSIXlt object).
>
> He seems to think that it's OK for R to segfault - I was wondering if
> someone else could lend a second opinion. My understanding is that we
> should try to avoid segfaulting as a way of handling errors, if only
> because they become much more difficult to debug when the R session is
> forced to quit.
>
> I don't know exactly which line is causing the bug, but looking at the
> code for do_formatPOSIXlt in "src/main/datetime.c", it seems that
> there would not be a huge performance penalty to add an extra sanity
> check to prevent this from occurring.
>
> Thank you,
>
> Frederick
>
> On Tue, Dec 06, 2016 at 04:37:20AM -0800, frederik at ofb.net wrote:
>> Hi all,
>>
>> I ran into a segfault while playing with dates.
>>
>>      $ R --no-init-file
>>      ...
>>      > library(lubridate); d=as.POSIXlt(floor_date(Sys.time(),"year")); d$zone=NULL; d$zone=""; d
>>
>>      Attaching package: ?lubridate?
>>
>>      The following object is masked from ?package:base?:
>>
>>          date
>>
>>      Warning message:
>>      package ?lubridate? was built under R version 3.4.0
>>
>>       *** caught segfault ***
>>      address (nil), cause 'unknown'
>>
>>      Traceback:
>>       1: format.POSIXlt(x, usetz = TRUE)
>>       2: format(x, usetz = TRUE)
>>       3: print(format(x, usetz = TRUE), ...)
>>       4: print.POSIXlt(x)
>>       5: function (x, ...) UseMethod("print")(x)
>>
>>      Possible actions:
>>      ...
>>
>> Hope I'm not doing something illegal...
>>
>> Thanks,
>>
>> Frederick
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] ok to segfault with POSIXlt zone=NULL zone=""?
Spencer Graves