#571601 python-apt: unexpected behaviour of TagFile.offset TagFile.jump skips sections

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Filippo Giunchedi
Date:
2010-03-20 22:48:10 UTC
Severity:
normal
#571601#5
Date:
2010-02-26 11:35:29 UTC
From:
To:
Hi,
while investigating #571470 (which shows similar symptoms but different
results) I incurred into an unexpected behavior of TagFile.offset and
TagFile.jump, specifically one would expect that after jump reading back the
offset would yield the same offset being jumped to, instead it seems to return
the next section (and not always). I used the attached test, running it on a
Packages file (any will do it seems, one from sid for example):

$ python aptpkg_bug.py  test_Packages
new parser offset 0, jumping to 833
after jump offset 1832
new parser offset 0, jumping to 2734
after jump offset 3557
new parser offset 0, jumping to 4529
after jump offset 5282
new parser offset 0, jumping to 6020
after jump offset 6922
new parser offset 0, jumping to 7772
after jump offset 8714
new parser offset 0, jumping to 10516
after jump offset 11545
new parser offset 0, jumping to 12349
after jump offset 13046
new parser offset 0, jumping to 14004
after jump offset 15118
new parser offset 0, jumping to 15938
after jump offset 16876
new parser offset 0, jumping to 17855
after jump offset 18741
new parser offset 0, jumping to 19700
after jump offset 20643
new parser offset 0, jumping to 21517
after jump offset 22371
new parser offset 0, jumping to 23203
after jump offset 24198
new parser offset 0, jumping to 25049
after jump offset 26480
new parser offset 0, jumping to 27689
after jump offset 28827
new parser offset 0, jumping to 30237
after jump offset 31029
new parser offset 0, jumping to 32018
after jump offset 33357
new parser offset 0, jumping to 34153
after jump offset 34153 equal
new parser offset 0, jumping to 35007
after jump offset 35007 equal
new parser offset 0, jumping to 36429
after jump offset 36429 equal
new parser offset 0, jumping to 38115
after jump offset 38115 equal
new parser offset 0, jumping to 39123
after jump offset 39123 equal
new parser offset 0, jumping to 40157
after jump offset 40157 equal
new parser offset 0, jumping to 41155
after jump offset 41155 equal
new parser offset 0, jumping to 43250
after jump offset 43250 equal

of course the number of sections yielded is lower than the Packages file.
Is this documented/wanted/expected? Seems rather odd.

thanks,
filippo

#571601#10
Date:
2010-03-20 22:45:00 UTC
From:
To:
reassign 571601 apt
tag 571601 confirmed
thanks
[...]

Even the following two yield different results; although one would expect
the file to always jump to 0.
  (1) step(); jump(0); step();
  (2) step(); jump(0); jump(0); step();

The first one would yield the same section in all three actions; whereas
the second one would step one section forward. I attached a C++ test case
for that one.

But both cases are bugs in apt itself, and not specific to python-apt. In
your case, jumping to offset - 1 might help (or to tagfile.offset -
len(section)).

My issue could probably be fixed by adding
   // Not jumping at all.
   if (Offset == iOffset)
      return true;
to the top of Jump() in tagfile.cc; but I believe both issues are
related and there is a more complicated issue somewhere in the
code.