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 778705 - Don't crash when marshalling an unsafe integer from introspection
Don't crash when marshalling an unsafe integer from introspection
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
1.47.x
Other Linux
: Normal major
: ---
Assigned To: Philip Chimento
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2017-02-15 19:05 UTC by Philip Chimento
Modified: 2017-02-25 06:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
arg: Warn on lossy conversion from (u)int64 (3.11 KB, patch)
2017-02-24 06:56 UTC, Philip Chimento
committed Details | Review

Description Philip Chimento 2017-02-15 19:05:22 UTC
The following crashes, at least in SpiderMonkey debug mode:

    gjs> const GLib = imports.gi.GLib;
    gjs> GLib.MAXINT64
    Assertion failure: T(double(t)) == t (value creation would be lossy), at /blah/include/mozjs-38/js/Value.h:1596
    Segmentation fault (core dumped)

When marshalling 64-bit values from gobject introspection, we should check for this, and perhaps emit a warning to the developer.
Comment 1 Philip Chimento 2017-02-24 06:56:54 UTC
Created attachment 346614 [details] [review]
arg: Warn on lossy conversion from (u)int64

Previously, a conversion from 64-bit integer that could not be stored
exactly in a double, would trip an assertion in debug mode SpiderMonkey.
This new behaviour in SpiderMonkey 38 would cause code like
"GLib.MAXINT64" to crash.

Instead, we check for that situation, log a warning for the developer,
and proceed with the lossy value.
Comment 2 Cosimo Cecchi 2017-02-25 03:21:25 UTC
Review of attachment 346614 [details] [review]:

Looks good.
Comment 3 Philip Chimento 2017-02-25 06:00:36 UTC
Attachment 346614 [details] pushed as 048fcee - arg: Warn on lossy conversion from (u)int64