Buggy localtime() on Windows and 32-bit platforms

Bug #1674195 reported by Florent Gallaire on 2017-03-20
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Undecided
Unassigned
Breezy
Undecided
Unassigned

Bug Description

[flext@web99 tb]$ python2.7 ../BZRR/fix-gmtime-lite/bzr log --timezone local
bzr: ERROR: exceptions.ValueError: timestamp out of range for platform time_t

Traceback (most recent call last):
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/commands.py", line 930, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/commands.py", line 1121, in run_bzr
    ret = run(*run_argv)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/commands.py", line 673, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/commands.py", line 697, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/cleanup.py", line 136, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/cleanup.py", line 166, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/commands.py", line 1138, in ignore_pipe
    result = func(*args, **kwargs)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/builtins.py", line 2893, in run
    Logger(b, rqst).show(lf)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/log.py", line 382, in show
    self._show_body(lf)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/log.py", line 412, in _show_body
    lf.log_revision(lr)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/log.py", line 1570, in log_revision
    lines.append('timestamp: %s' % (self.date_string(revision.rev),))
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/log.py", line 1538, in _date_string_with_timezone
    self.show_timezone)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/osutils.py", line 865, in format_date
    _format_date(t, offset, timezone, date_fmt, show_offset)
  File "/home/flext/BZRR/fix-gmtime-lite/bzrlib/osutils.py", line 925, in _format_date
    tt = time.localtime(t)
ValueError: timestamp out of range for platform time_t

bzr 2.8.0dev1 on python 2.7.12 (Linux-2.6.18-416.el5PAE-i686-with-
    redhat-5.11-Final)
arguments: ['../BZRR/fix-gmtime-lite/bzr', 'log', '--timezone', 'local']
plugins: bash_completion[2.8.0dev1], changelog_merge[2.8.0dev1],
    grep[2.8.0dev1], launchpad[2.8.0dev1], netrc_credential_store[2.8.0dev1],
    news_merge[2.8.0dev1], po_merge[2.8.0dev1], weave_fmt[2.8.0dev1]
encoding: 'utf-8', fsenc: 'UTF-8', lang: 'fr_FR.UTF-8'

Related branches

description: updated
Jelmer Vernooij (jelmer) wrote :

Can you provide some more context on what is actually going wrong here? How can we reproduce this bug?

Florent Gallaire (fgallaire) wrote :

bzr log --timezone local

The calculation of the localtime use datetime.fromtimestamp() and datetime.utcfromtimestamp() that are as buggy on Windows with negative timestamp as on 32-bit platforms with timestamp outside of the 32-bit range.

Fixed this by switching to 'original' timezone if 'local' is buggy (anyway it's only a showing log option,so not really important, but should never fail).

Jelmer Vernooij (jelmer) wrote :

If 'local' doesn't work for some reason, we should tell the user and suggest they use "--timezone original" rather than silently ignoring their (explicit) preference.

Jelmer Vernooij (jelmer) wrote :

I don't follow why this causes out of range errors. What is the value of the t variable when you hit this issue?

Florent Gallaire (fgallaire) wrote :

> If 'local' doesn't work for some reason, we should tell the user and suggest they use "--timezone original" rather than silently ignoring their (explicit) preference.

In theory, but not practically. Do you really want an error message for 1 commit /1000 of your history and be forced to switch to 'original' for the 999 commits that you can show as 'local' without problem ?

> I don't follow why this causes out of range errors. What is the value of the t variable when you hit this issue?

http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/revision/6622#bzrlib/tests/blackbox/test_commit.py

On Sat, Dec 02, 2017 at 04:46:26PM -0000, Florent Gallaire wrote:
> > If 'local' doesn't work for some reason, we should tell the user and
> suggest they use "--timezone original" rather than silently ignoring
> their (explicit) preference.
>
> In theory, but not practically. Do you really want an error message for
> 1 commit /1000 of your history and be forced to switch to 'original' for
> the 999 commits that you can show as 'local' without problem ?
>
> > I don't follow why this causes out of range errors. What is the value
> of the t variable when you hit this issue?
>
> http://bazaar.launchpad.net/~bzr-
> pqm/bzr/bzr.dev/revision/6622#bzrlib/tests/blackbox/test_commit.py
I'm not sure I understand what this is actually trying to fix; I've
followed up to https://bugs.launchpad.net/bzr/+bug/1670243

Jelmer

--
Jelmer Vernooij <email address hidden>
PGP Key: https://www.jelmer.uk/D729A457.asc

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers