Download it now!
Bug 102511 - LibreOfficeKit has wrong introspection data w/gobject-introspection < 1.42
Summary: LibreOfficeKit has wrong introspection data w/gobject-introspection < 1.42
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All Linux (All)
: medium normal
Assignee: Pranav Kant
URL:
Whiteboard: target:5.3.0 target:5.4.0
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-25 17:28 UTC by Mike Gorse
Modified: 2017-03-17 09:14 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Patch. (3.22 KB, patch)
2017-03-13 16:20 UTC, Mike Gorse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Gorse 2016-09-25 17:28:36 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0
Build Identifier: 10m0(Build:2)

Libreoffice will accept versions of gobject-introspection as far back as 1.32.0 when configuring. However, LibreOfficeKit uses the (nullable) annotation, which was added in the 1.42 cycle. So, if an older version is installed, then introspection data for these functions will be generated without (nullable) for these functions, without any obvious indication that something has gone wrong (aside from possibly generating a warning when g-ir-scanner is run). This leads to unexpected behavior. For instance, lok_doc_view_new() might be called with an empty pPath string, rather than a null string, and the function does not check for an empty string and treat it as equivalent to NULL. We could do one of the following:
(1) replace (nullable) with (allow-none); the latter is supported by older versions of gobject-introspection and is equivalent to (nullable) for in parameters.
(2) Require at least version 1.42.0 of gobject-introspection.
(3) Ensure that these functions treat empty strings as equivalent to NULL.

Reproducible: Always

Steps to Reproduce:
1. Build LibreOffice on a GNOME 3.10-based system.
2. Install the resulting binaries/package.
3. Run a recent version of gnome-documents (or anything else that uses libreofficekit via gobject-introspection).
Actual Results:  
Gnome-documents crashed, since lok_doc_view_new() does not expect to be passed an empty string.

Expected Results:  
Gnome-documents does not crash. For SLE, I am patching to replace (nullable) with (allow-none), and gnome-documents starts normally.




Reset User Profile?No
Comment 1 Pranav Kant 2016-10-18 11:54:19 UTC
(In reply to Mike Gorse from comment #0)
> User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101
> Firefox/48.0
> Build Identifier: 10m0(Build:2)
> 
> Libreoffice will accept versions of gobject-introspection as far back as
> 1.32.0 when configuring. However, LibreOfficeKit uses the (nullable)
> annotation, which was added in the 1.42 cycle. So, if an older version is
> installed, then introspection data for these functions will be generated
> without (nullable) for these functions, without any obvious indication that
> something has gone wrong (aside from possibly generating a warning when
> g-ir-scanner is run). This leads to unexpected behavior. For instance,
> lok_doc_view_new() might be called with an empty pPath string, rather than a
> null string, and the function does not check for an empty string and treat
> it as equivalent to NULL. We could do one of the following:
> (1) replace (nullable) with (allow-none); the latter is supported by older
> versions of gobject-introspection and is equivalent to (nullable) for in
> parameters.

allow-none is deprecated since 1.42; How about putting both allow-none and nullable together wherever required to keep the backward compatibility upto 1.32 and then we can remove (allow-none) when we bump the version in future.

My quick tweaking session with .gir and .typelib files seems to suggest that this should fix the issue, so hopefully this should be sufficient to address the crash. However, if we face more problems other than this, I think better to just bump the GI version.
Comment 2 Commit Notification 2016-10-21 06:12:43 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=84bfe584e4bd03a7b6e2c1e68c65bf99ae83c839

tdf#102511: Add (allow-none) for backward GI compatibility

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 Mike Gorse 2017-03-13 16:18:50 UTC
Unfortunately, the patch that was committed to fix this isn't quite right and doesn't really do anything. There should only be a : after the final annotation; the parser interprets everything after the : as documentation and ignores the allow-none annotation. The following appears in the gir, for instance:
          <parameter name="pPath" transfer-ownership="none">
            <doc xml:space="preserve">(allow-none): LibreOffice install path. Pass null to set it to default path which in most cases would be $libdir/libreoffice/program</doc>
Comment 4 Mike Gorse 2017-03-13 16:20:07 UTC
Created attachment 131855 [details]
Patch.
Comment 5 Pranav Kant 2017-03-13 16:41:19 UTC
Thanks for the patch. Indeed it looks correct, not sure how the wrong version got in even though I remember having verified the fix on my local.

Would it be possible for you to push the patch to gerrit ? If not (assuming its your first patch), I can commit it for you against your name, in that case, you need to send your license statement to the mailing list as described here[1]

[1] https://wiki.documentfoundation.org/Development/GetInvolved#Connect_to_our_communication_channels
Comment 6 Mike Gorse 2017-03-14 01:00:12 UTC
Just pushed to gerrit.
Comment 7 Commit Notification 2017-03-15 14:19:14 UTC
Mike Gorse committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=2ba485158bfa089e931c0c3e29389fe64a42dd4d

tdf#102511: Fix gobject-introspection annotation syntax

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.