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

Closed
opened 2015-07-07 17:58:48 +00:00 by daira · 6 comments
daira commented 2015-07-07 17:58:48 +00:00
Owner
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.

``` 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.
tahoe-lafs added the
code-mutable
normal
defect
1.10.1
labels 2015-07-07 17:58:48 +00:00
tahoe-lafs added this to the 1.11.0 milestone 2015-07-07 17:58:48 +00:00
tahoe-lafs changed title 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 2015-07-07 19:08:55 +00:00
daira commented 2015-07-07 19:10:11 +00:00
Author
Owner

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

The exception raised should be as documented in `interfaces.py`, per #2461.
daira commented 2015-07-07 20:15:47 +00:00
Author
Owner

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.

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.
daira commented 2015-07-07 23:13:20 +00:00
Author
Owner

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.

Replying to [daira](/tahoe-lafs/trac-2024-07-25/issues/2462#issuecomment-139220): > 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.
tahoe-lafs modified the milestone from 1.11.0 to 1.10.2 2015-07-17 21:53:09 +00:00
Brian Warner <warner@lothar.com> commented 2015-07-28 18:04:14 +00:00
Author
Owner

In /tahoe-lafs/trac-2024-07-25/commit/9076db137ac5fa5c1efd63b26970803cbc59a654:

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

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
In [/tahoe-lafs/trac-2024-07-25/commit/9076db137ac5fa5c1efd63b26970803cbc59a654](/tahoe-lafs/trac-2024-07-25/commit/9076db137ac5fa5c1efd63b26970803cbc59a654): ``` Remove some bare asserts in retrieve.py (there are still quite a few left). refs #2462 Signed-off-by: Daira Hopwood <daira@jacaranda.org> ```
Brian Warner <warner@lothar.com> commented 2015-07-28 20:40:26 +00:00
Author
Owner

In /tahoe-lafs/trac-2024-07-25/commit/29ab496bd75c8f9c1891f7a97ff9e682c79277e4:

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

Replace them with _assert() or precondition(). Closes ticket:2462.
In [/tahoe-lafs/trac-2024-07-25/commit/29ab496bd75c8f9c1891f7a97ff9e682c79277e4](/tahoe-lafs/trac-2024-07-25/commit/29ab496bd75c8f9c1891f7a97ff9e682c79277e4): ``` mutable/retrieve.py: remove all bare assert()s Replace them with _assert() or precondition(). Closes ticket:2462. ```
tahoe-lafs added the
fixed
label 2015-07-28 20:40:26 +00:00
Brian Warner <warner@lothar.com> closed this issue 2015-07-28 20:40:26 +00:00
daira commented 2015-07-28 22:00:38 +00:00
Author
Owner

Reviewed, +1.

Reviewed, +1.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tahoe-lafs/trac-2024-07-25#2462
No description provided.