After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796012 - Several places in rebase.py incorrectly use `match.groups(1)` instead of `match.group(1)`, one causes a crash
Several places in rebase.py incorrectly use `match.groups(1)` instead of `mat...
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
1.28
Other Linux
: Normal critical
: 1.29
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2018-05-10 18:51 UTC by Adam Williamson
Modified: 2018-05-10 19:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix for the bug (2.67 KB, patch)
2018-05-10 18:51 UTC, Adam Williamson
committed Details | Review

Description Adam Williamson 2018-05-10 18:51:35 UTC
Created attachment 371907 [details] [review]
fix for the bug

There are several incorrect uses of `match.groups(1)` instead of `match.group(1)` in rebase.py - one was fixed in https://git.gnome.org/browse/gtk-doc/commit/?id=b77d97bfe0186eb727604dbad565dc4dde0eb273 , but three others remained.

`match.groups(1)` is not *invalid*, but it does not do what any of these calls expect. The intent in each case is to get the contents of the subgroup 1 match as a string, but `match.groups(1)` doesn't do that. It returns a tuple of *all* the subgroup matches, with `1` used as the value for any which didn't actually capture any text (instead of the default `None` - that's what passing an arg to `groups()` does, changes the value used for subgroups that didn't capture anything).

The case of this in `ReadIndex` would cause a crash if hit:

Traceback (most recent call last):
  • File "/usr/bin/gtkdoc-rebase", line 56 in <module>
    sys.exit(rebase.run(options))
  • File "/usr/share/gtk-doc/python/gtkdoc/rebase.py", line 75 in run
    ScanDirectory(dir, options)
  • File "/usr/share/gtk-doc/python/gtkdoc/rebase.py", line 133 in ScanDirectory
    ScanDirectory(subdir, options)
  • File "/usr/share/gtk-doc/python/gtkdoc/rebase.py", line 114 in ScanDirectory
    onlinedir = ReadIndex(scan_dir, entry)
  • File "/usr/share/gtk-doc/python/gtkdoc/rebase.py", line 160 in ReadIndex
    onlinedir = re.sub(r'''(.*/).*''', r'\1', match.groups(1))
  • File "/usr/lib64/python3.6/re.py", line 191 in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object

As with https://bugzilla.gnome.org/show_bug.cgi?id=796011 , this crash got much easier to hit in 1.28 because of the fix to the `ReadDevhelp` regex in https://git.gnome.org/browse/gtk-doc/commit/?id=b77d97bfe0186eb727604dbad565dc4dde0eb273 . The other two occurrences, if I'm reading the code right, would not cause crashes, but would cause `RebaseLink` to fail (and log "Can't determine package for 'foo'") in cases where it ought to work.

Patch attached.
Comment 1 Stefan Sauer (gstreamer, gtkdoc dev) 2018-05-10 19:47:39 UTC
Thanks for the patch. Pushed.