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 683271 - os-database: avoid crash during wizard if loading failed
os-database: avoid crash during wizard if loading failed
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-09-03 14:01 UTC by Marc-Andre Lureau
Modified: 2016-03-31 13:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
os-database: avoid crash during wizard if loading failed (2.65 KB, patch)
2012-09-03 14:01 UTC, Marc-Andre Lureau
committed Details | Review
osinfo: ignore db loading errors (1.53 KB, patch)
2012-09-04 15:15 UTC, Christophe Fergeau
committed Details | Review

Description Marc-Andre Lureau 2012-09-03 14:01:05 UTC
We can quite easily avoid a crash during wizard if the db couldn't be
loaded, although this really shouldn't happen.
Comment 1 Marc-Andre Lureau 2012-09-03 14:01:07 UTC
Created attachment 223324 [details] [review]
os-database: avoid crash during wizard if loading failed
Comment 2 Christophe Fergeau 2012-09-03 14:12:35 UTC
Review of attachment 223324 [details] [review]:

As I understand it, libosinfo will return a NULL database if there's an error parsing any of the databases files (or at least if there's an error parsing the additional file we're providing). Imo it should be made more robust wrt that, but ACK to your patch anyway, better to be robust when something unexpected happens.

::: src/os-database.vala
@@ +39,3 @@
                                                   out Media os_media,
                                                   Cancellable? cancellable) throws GLib.Error {
+        os_media = null;

Is it valid to set this to null while it's declared as "out Media os_media" ?
Comment 3 Marc-Andre Lureau 2012-09-03 14:25:55 UTC
(In reply to comment #2)
> Review of attachment 223324 [details] [review]:
> 
> As I understand it, libosinfo will return a NULL database if there's an error
> parsing any of the databases files (or at least if there's an error parsing the
> additional file we're providing). Imo it should be made more robust wrt that,
> but ACK to your patch anyway, better to be robust when something unexpected
> happens.
> 
> ::: src/os-database.vala
> @@ +39,3 @@
>                                                    out Media os_media,
>                                                    Cancellable? cancellable)
> throws GLib.Error {
> +        os_media = null;
> 
> Is it valid to set this to null while it's declared as "out Media os_media" ?

I think so, but I will change it to out Media? instead.
Comment 4 Marc-Andre Lureau 2012-09-03 14:27:03 UTC
Actually, iirc, out Media? means you can pass null as argument to the function, not that the out value can be null. All out arguments can return null. So I won't change it
Comment 5 Marc-Andre Lureau 2012-09-03 16:09:58 UTC
Attachment 223324 [details] pushed as 9748749 - os-database: avoid crash during wizard if loading failed
Comment 6 Christophe Fergeau 2012-09-04 15:15:16 UTC
Created attachment 223434 [details] [review]
osinfo: ignore db loading errors

When reading libosinfo OS database, errors will get reported when a
file is invalid, missing, ... When this happens, we currently
give up on using libosinfo. This commit catches osinfo DB load errors,
but make sure we still try to use the libosinfo DB. At worse it will
be empty, but in most cases it should give us access to a partial
DB.
Comment 7 Christophe Fergeau 2012-09-04 15:19:00 UTC
This new patch should give us better behaviour when falling back.
Comment 8 Marc-Andre Lureau 2012-09-04 15:54:35 UTC
Review of attachment 223434 [details] [review]:

ack
Comment 9 Christophe Fergeau 2012-09-05 13:32:44 UTC
Attachment 223434 [details] pushed as f3583de - osinfo: ignore db loading errors