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 624811 - Segfault while wrapping a boxed type
Segfault while wrapping a boxed type
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal major
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks: 632109
 
 
Reported: 2010-07-20 10:56 UTC by Giovanni Campagna
Modified: 2010-11-19 21:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add support for (out caller-allocates) (6.43 KB, patch)
2010-08-11 22:21 UTC, Maxim Ermilov
committed Details | Review

Description Giovanni Campagna 2010-07-20 10:56:46 UTC
When copying a boxed type to be wrapped with a JS object, sometimes g_boxed_copy is passed garbage as src_boxed (and therefore it segfaults).

How to reproduce:
I encountered this using GnomeBluetooth, which uses a Gtk.TreeStore. Trying to obtain a Gtk.TreeIter, gjs reliably segfaults.

Code:
const Blueooth = imports.gi.GnomeBluetooth
let client = new Bluetooth.BluetoothClient()
let model = client.get_model() /* is a Gtk.TreeStore, implements Gtk.TreeModel */
let iter = model.get_iter_first() /* segfault*/

Comments:
it may be specific to Gtk.TreeIters (they are not expected to be copied or freed and are not actually boxed types).
Comment 1 Colin Walters 2010-07-20 11:37:26 UTC
This is actually gjs' lack of support for (out caller-allocates), see bug 604749
Comment 2 Maxim Ermilov 2010-08-11 22:21:07 UTC
Created attachment 167675 [details] [review]
add support for (out caller-allocates)
Comment 3 Giovanni Campagna 2010-10-08 17:31:04 UTC
Almost three months have passed since this bug was first reported, and (out caller-allocates) was added to gobject-introspection.
Any progress reviewing the patch?
Comment 4 Colin Walters 2010-11-17 15:39:54 UTC
Review of attachment 167675 [details] [review]:

::: gi/function.c
@@ +525,3 @@
+                        case GI_INFO_TYPE_ENUM:
+                GITypeTag type_tag;
+            if (g_arg_info_is_caller_allocates(&arg_info)) {

Just error if this happens; I'll make sure the scanner isn't generating them.

@@ +545,3 @@
+                case GI_TYPE_TAG_UINT64:
+                case GI_TYPE_TAG_FLOAT:
+                case GI_TYPE_TAG_DOUBLE:

The same for these, just error out.  We only want to support _INTERFACE and _UNION basically.

@@ +756,3 @@
 
+            type_tag = g_type_info_get_tag(&arg_type_info);
+            if (type_tag == GI_TYPE_TAG_INTERFACE) {

Aren't we missing a check for g_arg_info_is_caller_allocates(&arg_info) here?

@@ +762,3 @@
+                interface_info = g_type_info_get_interface(&arg_type_info);
+                interface_type = g_base_info_get_type(interface_info);
+                if (interface_type == GI_INFO_TYPE_STRUCT) {

Missing handling for GI_INFO_TYPE_UNION.