trying to make tracebacks reproducible

Greg Ward greg-hg at gerg.ca
Thu Jul 1 16:31:22 CDT 2010


On Thu, Jul 1, 2010 at 2:21 PM, Christian Ebert <blacktrash at gmx.net> wrote:
> Since a few days -- sorry for being vague, but this is actually
> part of the problem, I _sometimes_ get tracebacks with
> crew-stable (basically 1.6 I'd say). I cannot reproduce them
> "reliably", i.e. in the following example, I reissued the command
> and got the diff as expected. I can reduce the loaded extensions
> etc. but I'd like to reproduce this reliably first. It seems to
> happen at random - well, in the true sense of the word, if you
> look at the final lines of the traceback.
[...]
> $ hg diff -r default
> ** unknown exception encountered, details follow
> ** report bug details to http://mercurial.selenic.com/bts/
> ** or mercurial at selenic.com
> ** Python 2.6.5 (r265:79063, May 13 2010, 09:27:41) [GCC 4.0.1 (Apple Inc. build 5493)]
> ** Mercurial Distributed SCM (version 1.5.4+190-521c8e0c93bf)
> ** Extensions loaded: keyword, mq, convert, patchbomb, graphlog, record, extdiff, color, pager, crecord
> Traceback (most recent call last):
>  File "/usr/local/bin/hg", line 27, in <module>
>    mercurial.dispatch.run()
[...]
>  File "/usr/local/lib/python2.6/site-packages/hgext/mq.py", line 2791, in mqcommand
>    return orig(ui, repo, *args, **kwargs)
>  File "/usr/local/lib/python2.6/site-packages/mercurial/util.py", line 408, in check
>    return func(*args, **kwargs)
>  File "/usr/local/lib/python2.6/site-packages/mercurial/commands.py", line 1452, in diff
>    cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat)
>  File "/usr/local/lib/python2.6/site-packages/mercurial/cmdutil.py", line 677, in diffordiffstat
>    changes, diffopts):
>  File "/usr/local/lib/python2.6/site-packages/mercurial/patch.py", line 1492, in difflabel
>    for chunk in func(*args, **kw):
>  File "/usr/local/lib/python2.6/site-packages/mercurial/patch.py", line 1449, in diff
>    changes = repo.status(ctx1, ctx2, match=match)
>  File "/usr/local/lib/python2.6/site-packages/mercurial/localrepo.py", line 1088, in status
>    mf2.set(f, ctx2.flags(f))
>  File "/usr/local/lib/python2.6/site-packages/mercurial/context.py", line 737, in flags
>    flag = findflag(self._parents[0])
>  File "/usr/local/lib/python2.6/site-packages/mercurial/context.py", line 731, in findflag
>    ff = self._repo.dirstate.flagfunc(lambda x: flag or '')
>  File "/usr/local/lib/python2.6/site-packages/mercurial/dirstate.py", line 131, in flagfunc
>    if self._checklink:
>  File "/usr/local/lib/python2.6/site-packages/mercurial/util.py", line 163, in __get__
>    result = self.func(obj)
>  File "/usr/local/lib/python2.6/site-packages/mercurial/dirstate.py", line 115, in _checklink
>    return util.checklink(self._root)
>  File "/usr/local/lib/python2.6/site-packages/mercurial/util.py", line 697, in checklink
>    name = tempfile.mktemp(dir=path, prefix='hg-checklink-')
>  File "/usr/local/lib/python2.6/site-packages/mercurial/demandimport.py", line 75, in __getattribute__
>    self._load()
>  File "/usr/local/lib/python2.6/site-packages/mercurial/demandimport.py", line 47, in _load
>    mod = _origimport(head, globals, locals)
>  File "/sw/lib/python2.6/tempfile.py", line 34, in <module>
>    from random import Random as _Random
>  File "/usr/local/lib/python2.6/site-packages/mercurial/demandimport.py", line 106, in _demandimport
>    mod = _origimport(name, globals, locals)
>  File "/sw/lib/python2.6/random.py", line 59, in <module>
>    LOG4 = _log(4.0)
> ValueError: math domain error

That is absolutely totally bizarre.  This is completely deterministic
code; it's just random.py's setup.  It saves log(4.0) in a constant,
presumably as a performance tweak.

I'm looking in the source for the 'math' module (Modules/mathmodule.c)
from Python trunk (2.7-ish).  There are only two reasons why it can
raise "ValueError: math domain error":

  1) errno is set to EDOM by some call into the standard C library
(libm, I presume) -- eg. caller passes negative number to libm's log()
  2) caller passes x < 0 to log()

Clearly random.py is not passing a negative number to math.log().
This smells like either a deep and bizarre Python bug, a deep and
bizarre bug in libm, or cosmic rays.  I am inclined to blame cosmic
rays (or bad memory).  Try rebooting and see if the problem goes away.
 Also try checking your RAM.

Greg


More information about the Mercurial-devel mailing list