3609: Error displaying diff, wrapping index char traceback

csma****@gmai***** (Google Code) (Is this you? Claim this profile.)
chipx86
chipx86
June 1, 2015
What version are you running?
2.0.8

What's the URL of the page containing the problem?
http://<host behind firewall>.cisco.com/r/10256/diff/#

What steps will reproduce the problem?
1. Haven't figured out the exact parameters in which certain file diffs aren't displayed. It is happening fairly often though.
2. In one case, there was a large diff that had a piece:
+            goto error;
+    }
     /* 

which would work fine, but when changed, removing a trailing space, to:

+            goto error;
+    }
+    /*

it would blow up.


What is the expected output? What do you see instead?
Expect to see the diff of a file.
Instead, see
 There was an error displaying this diff.
string index out of range

Traceback (most recent call last):
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/views.py", line 236, in get
    renderer = self.create_renderer(context, *args, **kwargs)
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/reviews/views.py", line 1088, in create_renderer
    *args, **kwargs)
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/views.py", line 328, in create_renderer
    self.diff_file = self._get_requested_diff_file()
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/views.py", line 369, in _get_requested_diff_file
    request=self.request)
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 383, in populate_diff_chunks
    chunks = generator.get_chunks()
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/chunk_generator.py", line 153, in get_chunks
    large_data=True)
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/Djblets-0.8.11-py2.7.egg/djblets/cache/backend.py", line 111, in cache_memoize
    data = lookup_callable()
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/chunk_generator.py", line 152, in <lambda>
    lambda: list(self._get_chunks_uncached()),
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/chunk_generator.py", line 266, in _get_chunks_uncached
    a[i1:i2], b[j1:j2], old_lines, new_lines)
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/chunk_generator.py", line 377, in _diff_line
    old_markup, new_markup, *indentation_change)
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/chunk_generator.py", line 425, in _highlight_indentation
    self._serialize_unindentation)
  File "/local/ichnaea_conf/site/python_ve/reviewboard_v2.0/lib/python2.7/site-packages/ReviewBoard-2.0.8-py2.7.egg/reviewboard/diffviewer/chunk_generator.py", line 441, in _wrap_indentation_chars
    while markup[start_pos] == '<':
IndexError: string index out of range

What operating system are you using? What browser?
Windows 7, Firefox 32.0.3, IE 10

Please provide any additional information below.

Maybe 1 in a couple hundred files are getting tracebacks instead of displaying their diffs after upgrading from 1.7.26 to 2.0.6 (and later to 2.0.8). Tracebacks would indicate an issue in the chunk_generator code. Diffs seem to be fine internally, just bombing when trying to display, as per logs.

There is supposedly one user on another team who is using IE (version ???) and can see the diff just fine. Not working on my IE, Firefox, or anyone else I can find's system. Strange to me that the browser would have anything to do with it.

Speculation:
I'm guessing the [new|old]_markup in _diff_line is being set to '', which when passed to _wrap_indentation_chars is blowing up, as ''[] will give an IndexError.
chipx86
#1 chipx86
Very strange. I'll unfortunately need a copy of a diff and source code to help figure this out.

In the diff you referenced above, were any lines indented/unindented?

Also, for the IE user, do you know if syntax highlighting was turned off for him/her?
  • +NeedInfo
  • +Component-DiffParser
  • +chipx86
#4 dan.sch*******@gmai***** (Google Code) (Is this you? Claim this profile.)
Hi,

We've encountered this issue too and I believe I've discovered the root cause (at least in our case). The ingredients are the following:
1. File contains a lot of lines with 0x0c (form feed - many vendor files include this for whatever reason)
2. Diff occurs late in the file (with some experimentation I could quantify this precisely - you'll see why in minute)
3. Diff is whitespace only

The root cause are the 0x0c's. The ReviewBoard diff viewer mistakenly counts these as two lines whereas other tools (svn diff, vim, etc) count them as one. As a result when the diff viewer applies the patch (which it seems to do correctly) it positions the view at the wrong line. The further into the file it is - depending on how many 0x0c's are in the file - the further the view is skewed. In our case the breaking point was somewhere around 18. Meaning that after 18 0x0c's were encountered it was skewed far enough that, if the diff is whitespace only - we see the error in the bug report. If the diff is NOT whitespace only there is no error, but the viewer takes you to the wrong line and the changes are not highlighted.

I hope this helps.

PS: apologies for multiple add/deletes of this comment - I didn't see a way to edit for typos after I've posted
#5 dan.sch*******@gmai***** (Google Code) (Is this you? Claim this profile.)
To follow-up: it appears the 0x0c (^L) issue has been previously reported in bug #2980.
david
#6 david
This was fixed in 2.0.13
  • -NeedInfo
    +Fixed