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 651892 - gjs fails when accessing fixed size array elements through gobject-introspection
gjs fails when accessing fixed size array elements through gobject-introspection
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2011-06-04 22:01 UTC by Mike Auty
Modified: 2017-01-06 04:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gnome-shell-extensions patch that causes the system-monitor crash (524 bytes, patch)
2011-06-04 22:01 UTC, Mike Auty
none Details | Review

Description Mike Auty 2011-06-04 22:01:45 UTC
Created attachment 189241 [details] [review]
gnome-shell-extensions patch that causes the system-monitor crash

Hi there,

So working on a system-monitor extension for I tried accessing glibtop_cpu's xcpu_total array and tried to return the first element, but got a segfault instead of the value I was after.  The easiest way to reproduce this is with the systemMonitor extension from gnome-shell-extensions (commit 31ee462a0b6ed8414361ccb6c1c6ca861bd7c2f8), with the attached patch.

The version of gjs I'm using is commit 39cf5d2f51dcad72a7e175f21a3ffe602b5dd4b3, everything else should be about version 3.0.2, but I'm happy to provide specifics if required.

I've managed to setup debugging, although not by "gnome-shell --replace -g" (since -g was an unknown option), not by "gdb gnome-shell > run --replace", since it warned of an already running compositing window manager.  Eventually I slid gdbserver into the startup process and the tapped it that way.  The following is the backtrace I got.  Please let me know if you need any further information...

(gdb) bt
  • #0 gjs_array_from_carray_internal
    at gi/arg.c line 1550
  • #1 gjs_array_from_carray
    at gi/arg.c line 1604
  • #2 gjs_value_from_g_argument
    at gi/arg.c line 2104
  • #3 boxed_field_getter
    at gi/boxed.c line 744
  • #4 CallJSPropertyOp
    at jscntxtinlines.h line 750
  • #5 get
    at jsscopeinlines.h line 263
  • #6 js_NativeGetInline
    at jsobj.cpp line 5251
  • #7 js_GetPropertyHelperWithShapeInline
    at jsobj.cpp line 5436
  • #8 js_GetPropertyHelperInline
    at jsobj.cpp line 5457
  • #9 js_GetPropertyHelper
    at jsobj.cpp line 5463
  • #10 js::Interpret
    at jsinterp.cpp line 4214
  • #11 js::RunScript
    at jsinterp.cpp line 653
  • #12 js::Execute
    at jsinterp.cpp line 1028
  • #13 EvaluateUCScriptForPrincipalsCommon
    at jsapi.cpp line 5059
  • #14 JS_EvaluateUCScriptForPrincipals
    at jsapi.cpp line 5086
  • #15 JS_EvaluateScriptForPrincipals
    at jsapi.cpp line 5109
  • #16 JS_EvaluateScript
    at jsapi.cpp line 5129
  • #17 gjs_context_eval
    at gjs/context.c line 943
  • #18 gnome_shell_plugin_start
    at gnome-shell-plugin.c line 180
  • #19 meta_plugin_manager_initialize
    at compositor/meta-plugin-manager.c line 129
  • #20 meta_compositor_manage_screen
    at compositor/compositor.c line 553
  • #21 enable_compositor
    at core/display.c line 382
  • #22 meta_display_open
    at core/display.c line 823
  • #23 meta_run
    at core/main.c line 554
  • #24 main
    at main.c line 509

Comment 1 Maxim Ermilov 2011-06-06 21:38:34 UTC
Hi,

Can you provide:
1. gobject-itrospection version
2. machine architecture type (x86 or x86_64)
3. xulrunner version ?
Comment 2 Mike Auty 2011-06-06 21:42:42 UTC
Yep,

1. gobject-introspection-0.10.8
2. x86_64 (I don't yet have an x86 system I can test it on)
3. xulrunner-2.0.1

These are all Gentoo built source packages, no special flags (other than -ggdb).  I'm more than happy to provide more information and/or test run scripts or programs if it'll help track down the problem?
Comment 3 Maxim Ermilov 2011-06-06 21:51:37 UTC
I think, gobject-introspection is too old. Can you reproduce this bug with current trunk version?
Comment 4 Mike Auty 2011-06-07 06:57:25 UTC
Hmmm, I'm having difficult building from master, it seems to require glib-types.h which glib-2.28.7 doesn't seem to provide.  I'll keep trying and see where I can get to, otherwise I'll have to verify this after the next gobject-introspection release...
Comment 5 Mike Auty 2011-06-07 09:27:28 UTC
Yep, looks like it was a recent (early April) change made to glib related to bug 646635.  I'm not keen to start testing glib-2.29 on my production system, so I'm afraid this will have to wait.  I'm happy for it to be marked as closed or later, and then reopen it if I still have the problems after the new glib/gobject-introspection come out...
Comment 6 Philip Chimento 2017-01-06 04:41:17 UTC
I believe this is fixed now, the following script succeeds for me (and prints out 64 integers):

const GTop = imports.gi.GTop;
let cpu = new GTop.glibtop_cpu();
GTop.glibtop_get_cpu(cpu);
print(cpu.xcpu_total);

If the extension still doesn't work for you, feel free to reopen the bug.