Patchwork obsstore: do not crash on invalid date when reading markers

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 19, 2014, 5:07 p.m.
Message ID <33d51be18d4555617996.1408468041@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5508/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 19, 2014, 5:07 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1408467666 25200
#      Tue Aug 19 10:01:06 2014 -0700
# Node ID 33d51be18d45556179966cd3d66833764f4c6de2
# Parent  3d33baa4c4269c682254d871039d7df1175b1856
obsstore: do not crash on invalid date when reading markers

If the value for date is invalid, we fall back to a default value (unix epoch).
Pierre-Yves David - Aug. 19, 2014, 5:08 p.m.
On 08/19/2014 10:07 AM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1408467666 25200
> #      Tue Aug 19 10:01:06 2014 -0700
> # Node ID 33d51be18d45556179966cd3d66833764f4c6de2
> # Parent  3d33baa4c4269c682254d871039d7df1175b1856
> obsstore: do not crash on invalid date when reading markers
>
> If the value for date is invalid, we fall back to a default value (unix epoch).

Folding this changesets into c10ae3fac552 currently in crew would be a 
good idea.

"obsmarker: add date as an explicit field"
Matt Mackall - Aug. 20, 2014, 6:10 a.m.
On Tue, 2014-08-19 at 10:08 -0700, Pierre-Yves David wrote:
> 
> On 08/19/2014 10:07 AM, Pierre-Yves David wrote:
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david@fb.com>
> > # Date 1408467666 25200
> > #      Tue Aug 19 10:01:06 2014 -0700
> > # Node ID 33d51be18d45556179966cd3d66833764f4c6de2
> > # Parent  3d33baa4c4269c682254d871039d7df1175b1856
> > obsstore: do not crash on invalid date when reading markers
> >
> > If the value for date is invalid, we fall back to a default value (unix epoch).
> 
> Folding this changesets into c10ae3fac552 currently in crew would be a 
> good idea.
> 
> "obsmarker: add date as an explicit field"

Done. However, debugobsolete is still broken.

e1a4afe4c5910ef1d24676b14e369a9d2c6feacf 49903a7cc3937db0e27a27ea178ca9f268adae95 0 (Wed May 09 11:57:52 2012 +0200) {'user': 'Pierre-Yves David <pierre-yves.david@logilab.fr>'}
4530b3307fb9ae7f24c7e3d5e7c3c172656ba686 0 (Tue May 08 20:55:23 2012 +0200) {'user': 'Pierre-Yves David <pierre-yves.david@ens-lyon.org>'}
f1bb4628eab4bd82c80d8d3880714c45daf6ea61 0 ** Unknown exception encountered with possibly-broken third-party extension dbsh
** which supports versions unknown of Mercurial.
** Please disable dbsh and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.5+ (default, Sep 17 2013, 15:31:50) [GCC 4.8.1]
** Mercurial Distributed SCM (version 3.1+138-d732ff677b96+20140813)
** Extensions loaded: strip, blackbox, color, convert, dbsh, drophack, evolve, extdiff, gpg, hggit, histedit, pager, patchbomb, perf, progress, rebase, record, share, shelve, transplant
Traceback (most recent call last):
  File "/home/mpm/bin/hg", line 43, in <module>
    mercurial.dispatch.run()
  File "/home/mpm/hg/mercurial/dispatch.py", line 28, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/home/mpm/hg/mercurial/dispatch.py", line 69, in dispatch
    ret = _runcatch(req)
  File "/home/mpm/hg/mercurial/dispatch.py", line 138, in _runcatch
    return _dispatch(req)
  File "/home/mpm/hg/mercurial/dispatch.py", line 825, in _dispatch
    cmdpats, cmdoptions)
  File "/home/mpm/hg/mercurial/dispatch.py", line 605, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/home/mpm/hg/mercurial/extensions.py", line 196, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/home/mpm/hg/hgext/color.py", line 433, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/home/mpm/hg/mercurial/dispatch.py", line 916, in _runcommand
    return checkargs()
  File "/home/mpm/hg/mercurial/dispatch.py", line 887, in checkargs
    return cmdfunc()
  File "/home/mpm/hg/mercurial/dispatch.py", line 822, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/home/mpm/hg/mercurial/util.py", line 551, in check
    return func(*args, **kwargs)
  File "/home/mpm/hg/mercurial/commands.py", line 2358, in debugobsolete
    cmdutil.showmarker(ui, m)
  File "/home/mpm/hg/mercurial/cmdutil.py", line 1206, in showmarker
    ui.write('(%s) ' % util.datestr(marker.date()))
  File "/home/mpm/hg/mercurial/obsolete.py", line 227, in date
    return self._decodedmeta
ValueError: could not convert string to float: (1341873848.7012601,
Pierre-Yves David - Aug. 20, 2014, 6:43 a.m.
On 08/19/2014 11:10 PM, Matt Mackall wrote:
> On Tue, 2014-08-19 at 10:08 -0700, Pierre-Yves David wrote:
>>
>> On 08/19/2014 10:07 AM, Pierre-Yves David wrote:
>>> # HG changeset patch
>>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>>> # Date 1408467666 25200
>>> #      Tue Aug 19 10:01:06 2014 -0700
>>> # Node ID 33d51be18d45556179966cd3d66833764f4c6de2
>>> # Parent  3d33baa4c4269c682254d871039d7df1175b1856
>>> obsstore: do not crash on invalid date when reading markers
>>>
>>> If the value for date is invalid, we fall back to a default value (unix epoch).
>>
>> Folding this changesets into c10ae3fac552 currently in crew would be a
>> good idea.
>>
>> "obsmarker: add date as an explicit field"
>
> Done. However, debugobsolete is still broken.
>
> e1a4afe4c5910ef1d24676b14e369a9d2c6feacf 49903a7cc3937db0e27a27ea178ca9f268adae95 0 (Wed May 09 11:57:52 2012 +0200) {'user': 'Pierre-Yves David <pierre-yves.david@logilab.fr>'}
> 4530b3307fb9ae7f24c7e3d5e7c3c172656ba686 0 (Tue May 08 20:55:23 2012 +0200) {'user': 'Pierre-Yves David <pierre-yves.david@ens-lyon.org>'}
> f1bb4628eab4bd82c80d8d3880714c45daf6ea61 0 ** Unknown exception encountered with possibly-broken third-party extension dbsh
> ** which supports versions unknown of Mercurial.
> ** Please disable dbsh and try your action again.
> ** If that fixes the bug please report it to the extension author.
> ** Python 2.7.5+ (default, Sep 17 2013, 15:31:50) [GCC 4.8.1]
> ** Mercurial Distributed SCM (version 3.1+138-d732ff677b96+20140813)
> ** Extensions loaded: strip, blackbox, color, convert, dbsh, drophack, evolve, extdiff, gpg, hggit, histedit, pager, patchbomb, perf, progress, rebase, record, share, shelve, transplant
> Traceback (most recent call last):
>    File "/home/mpm/bin/hg", line 43, in <module>
>      mercurial.dispatch.run()
>    File "/home/mpm/hg/mercurial/dispatch.py", line 28, in run
>      sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
>    File "/home/mpm/hg/mercurial/dispatch.py", line 69, in dispatch
>      ret = _runcatch(req)
>    File "/home/mpm/hg/mercurial/dispatch.py", line 138, in _runcatch
>      return _dispatch(req)
>    File "/home/mpm/hg/mercurial/dispatch.py", line 825, in _dispatch
>      cmdpats, cmdoptions)
>    File "/home/mpm/hg/mercurial/dispatch.py", line 605, in runcommand
>      ret = _runcommand(ui, options, cmd, d)
>    File "/home/mpm/hg/mercurial/extensions.py", line 196, in wrap
>      return wrapper(origfn, *args, **kwargs)
>    File "/home/mpm/hg/hgext/color.py", line 433, in colorcmd
>      return orig(ui_, opts, cmd, cmdfunc)
>    File "/home/mpm/hg/mercurial/dispatch.py", line 916, in _runcommand
>      return checkargs()
>    File "/home/mpm/hg/mercurial/dispatch.py", line 887, in checkargs
>      return cmdfunc()
>    File "/home/mpm/hg/mercurial/dispatch.py", line 822, in <lambda>
>      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
>    File "/home/mpm/hg/mercurial/util.py", line 551, in check
>      return func(*args, **kwargs)
>    File "/home/mpm/hg/mercurial/commands.py", line 2358, in debugobsolete
>      cmdutil.showmarker(ui, m)
>    File "/home/mpm/hg/mercurial/cmdutil.py", line 1206, in showmarker
>      ui.write('(%s) ' % util.datestr(marker.date()))
>    File "/home/mpm/hg/mercurial/obsolete.py", line 227, in date
>      return self._decodedmeta
> ValueError: could not convert string to float: (1341873848.7012601,

debugobsolete works fine on my side. Your traceback is also suspicious 
as the line does not match the error. Looks like some crazy race 
condition where you had module from differnt version being load in the 
same process.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -166,11 +166,14 @@  def _readmarkers(data):
         if len(metadata) != mdsize:
             raise util.Abort(_('parsing obsolete marker: metadata is too '
                                'short, %d bytes expected, got %d')
                              % (mdsize, len(metadata)))
         off += mdsize
-        date = util.parsedate(decodemeta(metadata).pop('date', '0 0'))
+        try:
+            date = util.parsedate(decodemeta(metadata).pop('date', '0 0'))
+        except util.Abort:
+            date = (0., 0)
 
         yield (pre, sucs, flags, metadata, date)
 
 def encodemeta(meta):
     """Return encoded metadata string to string mapping.