git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, Andreas Schwab <schwab@linux-m68k.org>,
	git@vger.kernel.org
Subject: Re: [ANNOUNCE] Git v2.9.1
Date: Thu, 14 Jul 2016 09:45:12 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1607140913470.6426@virtualbox> (raw)
In-Reply-To: <xmqq8tx51hmx.fsf@gitster.mtv.corp.google.com>

Hi Junio,

On Wed, 13 Jul 2016, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > How about this one instead (which is part of the time_t-may-be-int64
> > branch on https://github.com/dscho/git which I still have to complete, as
> > some unsigned longs still slipped out of my previous net)? It strikes me
> > as much more robust:
> 
> Hmm, sorry, I do not see much upside here (iow, the 2038 test you
> came up with is as robust).

Unless you, or Peff, performed a thorough analysis whether the dates are
always cut off at 2038 holds true, I am highly doubtful that the previous
tes is robust at all. I certainly only tested on Windows and never
investigated how that 2038 came about. For what I know, it might be a
platform-dependent behavior of strtoul().

> When the internal time representation is updated from "unsigned long" to
> a signed and wider type [*1*], test-date has to stop reading the
> second-from-epoch input with strtol(),

It's strtoul(), actually.

> whose property that overflow will always result in LONG_MAX gives the
> robustness of the 2038 test, and needs to be updated.

So I got curious and looked at the man page. It says indeed that strtoul()
returns ULONG_MAX, which happens to translate into a date in the year
2038. It seems that this behavior is standardized:

	http://pubs.opengroup.org/onlinepubs/007908775/xsh/strtoul.html

although it does not say that ANSI C requires that behavior.

I also could not fail to notice that negative values will be parsed and
simply negated, and that return values 0 and ULONG_MAX *can* denote errors
(in which case errno is set, otherwise it is *not* set). Two rather
surprising facts, at least surprising to me, and facts that our code does
not deal with.

Please also note that ULONG_MAX is not required to be either 2^32-1 or
2^64-1. Which means that the 2038 test is really not robust.

> With this "is64bit" patch, you explicitly measure "unsigned long",
> knowing that our internal time representation currently is that type,
> and that would need to be updated when widening happens.  So both need
> to be updated anyway in the future.

Yes, I already update that in my topic branch.

Please note, however, that it is much more natural to update yet another
instance of "unsigned long" to "time_t" than having to explain how that
2038 test is affected.

Also note that the 640bit test is very explicit, and hence robust. As a
consequence it would skip the absurd dates on systems switching to
int128_t for time_t.

> The prerequisite name 64BITTIME that lost an underscore is harder to
> read, so there is a slight downside.

It is not a downside. It is something easily fixed.

> Moving of lazy_prereq to test-lib might be an upside if we were
> planning to add a test that depends on the system having or not
> having 64-bit timestamp elsewhere, but I do not think of a reason
> why such a new test cannot go to t0006-date, which has the perfect
> name for such a test and is not overly long right now (114 lines).

Happenstance. And I was merely imitating the patch of Peff thar I found on
gmane.

> So, unless you have a more solid reason to reject the updated t0006
> earlier in the thread, I am not sure what we'd gain by replacing it
> with this version.

My solid reason is that it is utterky unobvious why the magic number 2038
should do the work. You would have to spend quite some time to convince
the average programmer that it is correct.

Contrast that to the 64-bit test.

Ciao,
Dscho

  reply	other threads:[~2016-07-14  7:45 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-11 20:13 [ANNOUNCE] Git v2.9.1 Junio C Hamano
2016-07-11 21:35 ` Andreas Schwab
2016-07-11 23:54   ` Jeff King
2016-07-12  0:40     ` Anders Kaseorg
2016-07-12 14:06       ` Jeff King
2016-07-12  0:56     ` Eric Wong
2016-07-12  1:15       ` Jeff King
2016-07-12  1:59     ` Junio C Hamano
2016-07-12  3:57       ` Jeff King
2016-07-12 15:55         ` Junio C Hamano
2016-07-12  7:30       ` Johannes Schindelin
2016-07-12  7:39         ` Jeff King
2016-07-12 11:25           ` Johannes Schindelin
2016-07-12 14:04             ` Jeff King
2016-07-13 11:35               ` Johannes Schindelin
2016-07-13 16:03                 ` Junio C Hamano
2016-07-13 19:10                   ` Johannes Schindelin
2016-07-13 19:41                     ` Junio C Hamano
2016-07-14  7:50                       ` Johannes Schindelin
2016-07-12 18:12             ` Junio C Hamano
2016-07-13  1:53               ` Junio C Hamano
2016-07-13  2:01               ` Jeff King
2016-07-13 16:05                 ` Junio C Hamano
2016-07-13 18:52                   ` Johannes Schindelin
2016-07-13 19:07                     ` Junio C Hamano
2016-07-14  7:45                       ` Johannes Schindelin [this message]
2016-07-14  8:01                         ` Andreas Schwab
2016-07-14  8:15                         ` Jeff King
2016-07-14 16:06                       ` Johannes Schindelin
2016-07-12  7:40         ` Andreas Schwab
2016-07-12 10:57           ` Johannes Schindelin
2016-07-12 13:00             ` Andreas Schwab
2016-07-12 13:22               ` Johannes Schindelin
2016-07-12 13:31                 ` Andreas Schwab
2016-07-12 13:46                   ` Jeff King
2016-07-12 18:38                     ` Duy Nguyen
2016-07-13 11:29                       ` Johannes Schindelin
2016-07-13 11:25                   ` Johannes Schindelin
2016-07-12 14:34         ` Junio C Hamano
2016-07-12 15:16           ` Jeff King
2016-07-12 15:25             ` Junio C Hamano
2016-07-12 15:35               ` Jeff King
2016-07-12 15:41                 ` Junio C Hamano
2016-07-12 16:09                   ` Jeff King
2016-07-12 16:25                     ` Junio C Hamano
2016-07-13 14:00                       ` Johannes Schindelin
2016-07-13 16:10                         ` Junio C Hamano
2016-07-13 18:53                           ` Johannes Schindelin
2016-07-12 18:15                     ` Andreas Schwab
2016-07-13 20:43       ` Junio C Hamano
2016-07-14  7:38         ` Lars Schneider
2016-07-16  5:50           ` Duy Nguyen
2016-07-14  7:58         ` 32-bit Travis, was " Johannes Schindelin
2016-07-14  9:12           ` Mike Hommey
2016-07-14 10:58             ` Johannes Schindelin
2016-07-15  1:59               ` Mike Hommey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1607140913470.6426@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).