Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Issue 27472003: android: fix base::Time::FromLocalExploded() crash. (Closed)

Created:
7 years, 2 months ago by digit1
Modified:
7 years, 2 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

android: fix base::Time::FromLocalExploded() crash. This patch does the following: - Provide a work-around for an Android platform bug that happens on older Android releases (e.g. 4.1.2), but fixed on later ones (e.g. 4.3), where mktime() / mktime64() would return -1 even when passed proper time values. - Improve the code to properly deal with the fact that SysTime is actually int64 on Android, unlike other platforms, allowing us to remove the CHECK() that was triggered by the platform bug. - Add a new unit test to verify that the new code doesn't crash on Android 4.1.2 anymore, and returns the correct values. BUG=287821 R=jar@chromium.org,mark@chromium.org,brettw@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=229567

Patch Set 1 #

Total comments: 3

Patch Set 2 : git cl try #

Total comments: 2

Patch Set 3 : Use new code paths on all platforms. #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+68 lines, -7 lines) Patch
M base/time/time_posix.cc View 1 2 2 chunks +44 lines, -7 lines 0 comments Download
M base/time/time_unittest.cc View 1 2 chunks +24 lines, -0 lines 1 comment Download

Messages

Total messages: 11 (0 generated)
digit1
7 years, 2 months ago (2013-10-16 15:16:05 UTC) #1
jar (doing other things)
https://codereview.chromium.org/27472003/diff/1/base/time/time_posix.cc File base/time/time_posix.cc (right): https://codereview.chromium.org/27472003/diff/1/base/time/time_posix.cc#newcode211 base/time/time_posix.cc:211: timestruct.tm_isdst = -1; // attempt to figure it out ...
7 years, 2 months ago (2013-10-16 21:36:34 UTC) #2
digit1
https://codereview.chromium.org/27472003/diff/1/base/time/time_posix.cc File base/time/time_posix.cc (right): https://codereview.chromium.org/27472003/diff/1/base/time/time_posix.cc#newcode211 base/time/time_posix.cc:211: timestruct.tm_isdst = -1; // attempt to figure it out ...
7 years, 2 months ago (2013-10-17 14:00:26 UTC) #3
digit1
ping?
7 years, 2 months ago (2013-10-17 21:29:56 UTC) #4
jar (doing other things)
The patch looks good now... but it should probably be for all of posix, as ...
7 years, 2 months ago (2013-10-18 02:14:17 UTC) #5
digit1
https://chromiumcodereview.appspot.com/27472003/diff/7001/base/time/time_posix.cc File base/time/time_posix.cc (right): https://chromiumcodereview.appspot.com/27472003/diff/7001/base/time/time_posix.cc#newcode221 base/time/time_posix.cc:221: #if defined(OS_ANDROID) Thanks, I've remove the #if defined(OS_ANDROID) now. ...
7 years, 2 months ago (2013-10-18 08:54:59 UTC) #6
kerz_google
On 2013/10/18 08:54:59, digit1 wrote: > https://chromiumcodereview.appspot.com/27472003/diff/7001/base/time/time_posix.cc > File base/time/time_posix.cc (right): > > https://chromiumcodereview.appspot.com/27472003/diff/7001/base/time/time_posix.cc#newcode221 > ...
7 years, 2 months ago (2013-10-18 16:34:22 UTC) #7
jar (doing other things)
Patch set 3 LGTM
7 years, 2 months ago (2013-10-18 21:05:09 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/digit@chromium.org/27472003/34001
7 years, 2 months ago (2013-10-19 08:17:10 UTC) #9
commit-bot: I haz the power
Change committed as 229567
7 years, 2 months ago (2013-10-19 15:38:56 UTC) #10
jar (doing other things)
7 years, 2 months ago (2013-10-21 18:15:20 UTC) #11
Message was sent while issue was closed.
https://codereview.chromium.org/27472003/diff/34001/base/time/time_unittest.cc
File base/time/time_unittest.cc (right):

https://codereview.chromium.org/27472003/diff/34001/base/time/time_unittest.c...
base/time/time_unittest.cc:547: TEST_F(TimeTest,
FromLocalExplodedCrashOnAndroid) {
nit: IMO, you should have "similar" tests on all platforms.

You should try to deliberately pick times that don't exist in "common" time
zones, like here in the USA.  Most critically, you should test both "ambiguous"
date/time where there are two possible answers (because the clock was turned
back), and also where there is "no generic answer" because the clock was pushed
forward.

It was interesting that we had problems in Santiago, but currently, Santiago
does not have a time change on October 13th.... so this test seems especially
weak.

Suggestion (that should work cross platform?): Validate that 3 calls result in
integers that are nice and sequential.  The middle call should be the
"troublesome time," while the bracketing calls should be something like one day
earlier, and one day later.

This should be done for both a clock jumping forward, and a clock jumping
backwards chosen as the "troublesome" date.  In addition, you should verify that
the gap between the two bracketing times is either 49 hours (jump forward), or
47 hours (fall back), so that you know you are probably testing the
"troublesome" date.

Powered by Google App Engine
This is Rietveld 408576698