Code Monkey home page Code Monkey logo

Comments (3)

devbww avatar devbww commented on June 1, 2024

It looks like the expectation you are referring to is ...

EXPECT_EQ("-2147481748-01-01T00:00:00+00:00", format(RFC3339, tp, cut));

around line 1025. If so, my first concern is that the test has been changed because that line uses the timezone cut, whereas your output says utc.

That said, that part of the test is about conversions in the libc:UTC timezone, which means it mostly concerns the behavior of gmtime_r(3) from your C library.

It is difficult to say more without being able to run the code, but my first question would be "how does gmtime_r() behave on a time_t value of -67768040609740800?" My guess is that it fails. It should return {0, 0, 0, 1, 0, -2147483648}.

from cctz.

devbww avatar devbww commented on June 1, 2024

Did you discover anything about the behavior of your gmtime_r(), or is this no longer an issue?

from cctz.

kpozin avatar kpozin commented on June 1, 2024

I apologize for not getting back to this earlier.

Fuchsia uses musl for its libc implementation:

gmtime_r() for -67768040609740800 does indeed fail; it yields a tm with all fields set to 0.

These are the two underflow conditions in __secs_to_tm:

  if (t < INT_MIN * 31622400LL || t > INT_MAX * 31622400LL)
    return -1;
  if (years + 100 > INT_MAX || years + 100 < INT_MIN)
    return -1;

The second is the one that's triggered, with an off-by-one error. (years + 100 ends up being -2147483649.)

It appears there's a patch attempting to fix this that was never merged: https://www.openwall.com/lists/musl/2016/11/02/1
However, the patch is incomplete, because with it, the month ends up off by 2:

{0, 0, 0, 1, 2, -2147483648}

from cctz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.