[tahoe-lafs-trac-stream] [tahoe-lafs] #1418: "cannot convert float NaN to integer" in next_power_of_k, during upload via helper

tahoe-lafs trac at tahoe-lafs.org
Thu Jun 23 12:36:08 PDT 2011


#1418: "cannot convert float NaN to integer" in next_power_of_k, during upload via
helper
------------------------+---------------------------
     Reporter:  rycee   |      Owner:  rycee
         Type:  defect  |     Status:  new
     Priority:  major   |  Milestone:  undecided
    Component:  code    |    Version:  1.8.2
   Resolution:          |   Keywords:  helper upload
Launchpad Bug:          |
------------------------+---------------------------

Comment (by rycee):

 I don't have physical access to the machine but I ran memtester for quite
 some time and it didn't show anything.  Neither did some stress testing of
 `math.log`.  But running the trial thingy was good, I noticed that
 `allmydata.test.test_cli.Backup.test_backup` failed with an exception on
 the `x = int(math.log(n, k) + 0.5)` line.  And I found something that
 seems rather curious to me, putting `print math.log(10)` first in
 `next_power_of_k` and running `test_backup` gives
 {{{
 ...
   File "/home/rycee/allmydata-tahoe-1.8.2/src/allmydata/util/mathutil.py",
 line 32, in next_power_of_k
     print math.log(10)
 exceptions.ValueError: math domain error
 }}}
 Yeah, that's right.  Running `math.log(10)` gives an exception and since
 it's only run once I can't imagine it's being from the CPU being
 overloaded or anything.  Further:
 {{{
 $ python
 Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
 [GCC 4.4.5] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import math
 >>> math.log(10)
 2.3025850929940459
 }}}
 If I change `math.log(10)` to `math.log10(10)` it still gives the error.
 But – and hang on to your hat – if I use `math.sqrt(10)` it works, not
 only does the sqrt work but the `math.log(n, k)` a few lines down does as
 well!  With `next_power_of_k` defined
 {{{
 def next_power_of_k(n, k):
     hmmmm = math.sqrt(10)
     if n == 0:
         x = 0
     else:
         x = int(math.log(n, k) + 0.5)
     if k**x < n:
         return k**(x+1)
     else:
         return k**x
 }}}
 the unit test passes!

 Now, while this elegant fix removes the exception during backup the
 uploaded files unfortunately still fail `check --verify`).

 Anyway, obviously something strange happens with some floating point
 operations and like you said, some floating point mode is probably being
 altered when running tahoe but not otherwise.

 I also tried adding a print of `effective_segments` right after its
 assignment.  It turns out that this variable is being set to 1 when I try
 doing a `cp` of a 1kB file and 128 with a 10MB file.  I don't know if
 these values are OK but regardless, it appears that `next_power_of_k` is
 OK to call sometimes but not otherwise.

-- 
Ticket URL: <http://tahoe-lafs.org/trac/tahoe-lafs/ticket/1418#comment:13>
tahoe-lafs <http://tahoe-lafs.org>
secure decentralized storage


More information about the tahoe-lafs-trac-stream mailing list