#2462 closed defect (fixed)

remove bare asserts for segment out-of-range errors in mutable retrieve

Reported by: daira Owned by: warner
Priority: normal Milestone: 1.10.2
Component: code-mutable Version: 1.10.1
Keywords: cleanup error mutable retrieve download Cc:
Launchpad Bug:

Description (last modified by daira)

Traceback (most recent call last):
  File "/home/davidsarah/tahoe/git/trunk/src/allmydata/mutable/filenode.py", line 990, in <lambda>
    self._serializer.addCallback(lambda ignore: cb(*args, **kwargs))
  File "/home/davidsarah/tahoe/git/trunk/src/allmydata/mutable/filenode.py", line 980, in _read
    d = r.download(consumer, offset, size)
  File "/home/davidsarah/tahoe/git/trunk/src/allmydata/mutable/retrieve.py", line 244, in download
    self._setup_encoding_parameters()
  File "/home/davidsarah/tahoe/git/trunk/src/allmydata/mutable/retrieve.py", line 411, in _setup_encoding_parameters
    assert start < self._num_segments
exceptions.AssertionError: 

There are at least two bare asserts, one for the start segment and one for the end segment.

Change History (9)

comment:1 Changed at 2015-07-07T19:08:55Z by daira

  • Description modified (diff)
  • Status changed from new to assigned
  • Summary changed from remove bare assert for segment out-of-range error in mutable retrieve to remove bare asserts for segment out-of-range errors in mutable retrieve

comment:2 Changed at 2015-07-07T19:10:11Z by daira

The exception raised should be as documented in interfaces.py, per #2461.

comment:3 follow-up: Changed at 2015-07-07T20:15:47Z by daira

The current error behaviour is confusing; it appears that you can read one byte past the end of the file, only if the file is not a multiple of k bytes (i.e. at this API layer, you can read the dummy bytes that are added to make the size of the input to encoding a multiple of k bytes). This should probably be made stricter.

Last edited at 2015-07-07T20:16:32Z by daira (previous) (diff)

comment:4 in reply to: ↑ 3 Changed at 2015-07-07T23:13:20Z by daira

Replying to daira:

The current error behaviour is confusing; it appears that you can read one byte past the end of the file, only if the file is not a multiple of k bytes (i.e. at this API layer, you can read the dummy bytes that are added to make the size of the input to encoding a multiple of k bytes).

See https://github.com/tahoe-lafs/tahoe-lafs/commit/e437bfd64bf4fb6838036fde9aa05f987f911320#diff-8d5163da85905f8ddd5ce6a535206479R3403, which reads one byte past the end of the file, and passes. (The same thing happens when reading 101 bytes of a 100-byte SDMF file.) The explanation above may not be correct, though; it's just a guess.

comment:5 Changed at 2015-07-17T21:53:09Z by daira

  • Milestone changed from 1.11.0 to 1.10.2

comment:6 Changed at 2015-07-27T20:13:26Z by warner

  • Owner changed from daira to warner
  • Status changed from assigned to new

comment:7 Changed at 2015-07-28T18:04:14Z by Brian Warner <warner@…>

In 9076db137ac5fa5c1efd63b26970803cbc59a654/trunk:

Remove some bare asserts in retrieve.py (there are still quite a few left). refs #2462

Signed-off-by: Daira Hopwood <daira@…>

comment:8 Changed at 2015-07-28T20:40:26Z by Brian Warner <warner@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 29ab496bd75c8f9c1891f7a97ff9e682c79277e4/trunk:

mutable/retrieve.py: remove all bare assert()s

Replace them with _assert() or precondition(). Closes ticket:2462.

comment:9 Changed at 2015-07-28T22:00:38Z by daira

Reviewed, +1.

Note: See TracTickets for help on using tickets.