Bug 17272 - Sanitizer error in localtime.c
Summary: Sanitizer error in localtime.c
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 normal
Assignee: R-core
Depends on:
Reported: 2017-05-16 15:57 UTC by Jim Hester
Modified: 2017-05-16 20:39 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Jim Hester 2017-05-16 15:57:34 UTC
Similar to https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=17230, this undefined behavior was fixed upstream with https://github.com/eggert/tz/commit/3bf56b926fcf655531ff47cff716e81df28a6800, a simple port of the relevant code to R's fork is below.

I believe it should be triggered by first using an explicit timezone that has DST, and then not doing so.

    strftime("1979-10-14T1010", tz = "US/Central")
    strftime("1979-10-14T1010", tz = "")

Index: src/extra/tzone/localtime.c
--- src/extra/tzone/localtime.c (revision 72682)
+++ src/extra/tzone/localtime.c (working copy)
@@ -1237,6 +1237,8 @@
        lclptr->leapcnt = 0;            /* so, we're off a little */
        lclptr->timecnt = 0;
        lclptr->typecnt = 0;
+       lclptr->charcnt = 0;
+       lclptr->goback = lclptr->goahead = FALSE;
        lclptr->ttis[0].tt_isdst = 0;
        lclptr->ttis[0].tt_gmtoff = 0;
        lclptr->ttis[0].tt_abbrind = 0;
Comment 1 Jim Hester 2017-05-16 20:39:15 UTC
Note I am not exactly sure how to reproduce the original conditions with R's version of localtime.c. Compiling with `--with-internal-tzcode` and sanitizers turned out does produce a warning from a different area of the code however.

strftime("1979-10-14T1010", tz = "US/Central")
localtime.c:313:19: runtime error: left shift of negative value -1
localtime.c:322:19: runtime error: left shift of negative value -1