GJS can't call glibtop_init function from libgtop
System information
GJS 1.57.3-4-g739f625b on FreeBSD 12.0
Bug information
Steps to reproduce
- Just call
glibtop_init
fromGTop
and see it to fail.
Current behaviour
GJS complains it can't find glibtop_init_s
, but nobody is calling it. It is true that libgtop should not put an unexported function to its introspection data, but it is also unexpected for GJS to crash when the invalid function is never used.
$ gjs
gjs> const GTop = imports.gi.GTop;
gjs> GTop.glibtop_init();
error: GLib.Error g-invoke-error-quark: Could not locate glibtop_init_s: 'glibtop_init_s': Undefined symbol "glibtop_init_s"
gjs> GTop.glibtop_init();
**
Gjs:ERROR:/home/lantw44/gnome/source/gjs/gi/wrapperutils.h:981:static Prototype *GIWrapperPrototype<BoxedBase, BoxedPrototype, BoxedInstance, _GIBaseInfoStub>::for_js_prototype(JSContext *, JS::HandleObject) [Base = BoxedBase, Prototype = BoxedPrototype, Instance = BoxedInstance, Info = _GIBaseInfoStub]: assertion failed: (retval)
Bail out! Gjs:ERROR:/home/lantw44/gnome/source/gjs/gi/wrapperutils.h:981:static Prototype *GIWrapperPrototype<BoxedBase, BoxedPrototype, BoxedInstance, _GIBaseInfoStub>::for_js_prototype(JSContext *, JS::HandleObject) [Base = BoxedBase, Prototype = BoxedPrototype, Instance = BoxedInstance, Info = _GIBaseInfoStub]: assertion failed: (retval)
Redirecting call to abort() to mozalloc_abort
LibGTop-Server(c=79458): [WARNING] pid 79458 received eof.
Segmentation fault (core dumped)
#0 mozalloc_abort (msg=<optimized out>) at /home/lantw44/gnome/source/mozjs-60.1.0/memory/mozalloc/mozalloc_abort.cpp:33
#1 0x00000008025ba1ed in abort () at /home/lantw44/gnome/source/mozjs-60.1.0/memory/mozalloc/mozalloc_abort.cpp:80
#2 0x0000000800fa552e in g_assertion_message (domain=0x800263583 "Gjs", file=<optimized out>, line=<optimized out>,
func=0x8002666c9 "static Prototype *GIWrapperPrototype<BoxedBase, BoxedPrototype, BoxedInstance, _GIBaseInfoStub>::for_js_prototype(JSContext *, JS::HandleObject) [Base = BoxedBase, Prototype = BoxedPrototype, Instance"..., message=0x8049197a0 "assertion failed: (retval)") at ../../source/glib/glib/gtestutils.c:2895
#3 0x0000000800fa558e in g_assertion_message_expr (domain=0x800263583 "Gjs", file=0x8002680de "/home/lantw44/gnome/source/gjs/gi/wrapperutils.h", line=981,
func=0x8002666c9 "static Prototype *GIWrapperPrototype<BoxedBase, BoxedPrototype, BoxedInstance, _GIBaseInfoStub>::for_js_prototype(JSContext *, JS::HandleObject) [Base = BoxedBase, Prototype = BoxedPrototype, Instance"..., expr=<optimized out>) at ../../source/glib/glib/gtestutils.c:2921
#4 0x00000008002effdf in GIWrapperPrototype<BoxedBase, BoxedPrototype, BoxedInstance, _GIBaseInfoStub>::for_js_prototype (cx=0x803b0dc00, wrapper=...) at /home/lantw44/gnome/source/gjs/gi/wrapperutils.h:981
#5 0x00000008002eecad in GIWrapperInstance<BoxedBase, BoxedPrototype, BoxedInstance, void>::GIWrapperInstance (this=0x8050a5540, cx=0x0, obj=...) at /home/lantw44/gnome/source/gjs/gi/wrapperutils.h:1031
#6 0x00000008002ec66e in BoxedInstance::BoxedInstance (this=0x8050a5540, cx=0x0, obj=...) at /home/lantw44/gnome/source/gjs/gi/boxed.cpp:50
#7 0x00000008002ef084 in GIWrapperInstance<BoxedBase, BoxedPrototype, BoxedInstance, void>::new_for_js_object (cx=0x803b0dc00, obj=...) at /home/lantw44/gnome/source/gjs/gi/wrapperutils.h:1048
#8 0x00000008002efa9b in BoxedInstance::new_for_c_struct_impl<>(JSContext*, _GIBaseInfoStub*, void*) (cx=0x803b0dc00, info=<optimized out>, gboxed=0x8050eb000 <_glibtop_global_server>)
at /home/lantw44/gnome/source/gjs/gi/boxed.cpp:994
#9 0x00000008002e4e5c in gjs_value_from_g_argument (context=0x0, value_p=..., type_info=<optimized out>, arg=0x7fffffffc178, copy_structs=true) at /home/lantw44/gnome/source/gjs/gi/arg.cpp:2907
#10 0x00000008002f94c3 in gjs_invoke_c_function (context=0x803b0dc00, function=<optimized out>, obj=..., args=..., js_rval=..., r_value=0x0) at /home/lantw44/gnome/source/gjs/gi/function.cpp:1166
#11 0x00000008002fa352 in function_call (context=0x803b0dc00, js_argc=<optimized out>, vp=<optimized out>) at /home/lantw44/gnome/source/gjs/gi/function.cpp:1439
#12 0x0000000801eaa9d8 in js::CallJSNative (args=..., cx=<optimized out>, native=<optimized out>) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/JSContext-inl.h:290
#13 js::InternalCallOrConstruct (cx=0x803b0dc00, args=..., construct=js::NO_CONSTRUCT) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:450
#14 0x0000000801ea4dd0 in js::CallFromStack (cx=<optimized out>, args=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:523
#15 Interpret (cx=0x803b0dc00, state=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:3115
#16 0x0000000801e9ba29 in js::RunScript (cx=0x803b0dc00, state=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:418
#17 0x0000000801eab25b in js::ExecuteKernel (cx=0x0, script=..., envChainArg=..., newTargetValue=..., evalInFrame=..., result=0x0) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:701
#18 0x0000000801eab37e in js::Execute (cx=0x803b0dc00, script=..., envChainArg=..., rval=0x7fffffffcc30) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:733
#19 0x0000000802226725 in Evaluate (cx=0x803b0dc00, scopeKind=<optimized out>, env=..., optionsArg=..., srcBuf=..., rval=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/jsapi.cpp:4831
#20 0x0000000802226475 in JS::Evaluate (cx=0x803b0dc00, options=..., bytes=<optimized out>, length=<optimized out>, rval=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/jsapi.cpp:4871
#21 0x0000000800337a1a in gjs_console_eval_and_print (cx=0x803b0dc00, bytes=0x804919740 "GTop.glibtop_init();", length=20, lineno=<optimized out>) at /home/lantw44/gnome/source/gjs/modules/console.cpp:278
#22 0x0000000800337876 in gjs_console_interact (context=0x0, argc=<optimized out>, vp=<optimized out>) at /home/lantw44/gnome/source/gjs/modules/console.cpp:340
#23 0x0000000801eaa7df in js::CallJSNative (native=0x800337730 <gjs_console_interact(JSContext*, unsigned int, JS::Value*)>, args=..., cx=<optimized out>)
at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/JSContext-inl.h:290
#24 js::InternalCallOrConstruct (cx=0x803b0dc00, args=..., construct=js::NO_CONSTRUCT) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:468
#25 0x0000000801ea4dd0 in js::CallFromStack (cx=<optimized out>, args=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:523
#26 Interpret (cx=0x803b0dc00, state=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:3115
#27 0x0000000801e9ba29 in js::RunScript (cx=0x803b0dc00, state=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:418
#28 0x0000000801eab25b in js::ExecuteKernel (cx=0x0, script=..., envChainArg=..., newTargetValue=..., evalInFrame=..., result=0x0) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:701
#29 0x0000000801eab37e in js::Execute (cx=0x803b0dc00, script=..., envChainArg=..., rval=0x7fffffffd778) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/vm/Interpreter.cpp:733
#30 0x0000000802226725 in Evaluate (cx=0x803b0dc00, scopeKind=<optimized out>, env=..., optionsArg=..., srcBuf=..., rval=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/jsapi.cpp:4831
#31 0x00000008022268a0 in Evaluate (cx=0x803b0dc00, envChain=..., optionsArg=..., srcBuf=..., rval=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/jsapi.cpp:4845
#32 JS::Evaluate (cx=0x803b0dc00, envChain=..., optionsArg=..., srcBuf=..., rval=...) at /home/lantw44/gnome/source/mozjs-60.1.0/js/src/jsapi.cpp:4903
#33 0x000000080031f83b in GjsContextPrivate::eval_with_scope (this=0x803b4b0b0, scope_object=..., script=<optimized out>, script_len=52, filename=0x200836 "<stdin>", retval=...)
at /home/lantw44/gnome/source/gjs/gjs/context.cpp:1005
#34 0x000000080031f4d5 in GjsContextPrivate::eval (this=0x803b4b0b0, script=0x8003fe140 "const Console = imports.console; Console.interact();", script_len=52, filename=0x200836 "<stdin>", exit_status_p=0x7fffffffd898,
error=0x7fffffffd8a0) at /home/lantw44/gnome/source/gjs/gjs/context.cpp:878
#35 0x000000080031f37a in gjs_context_eval (js_context=0x803b4b190, script=0x8003fe140 "const Console = imports.console; Console.interact();", script_len=52, filename=0x200836 "<stdin>", exit_status_p=0x7fffffffd898,
error=0x7fffffffd8a0) at /home/lantw44/gnome/source/gjs/gjs/context.cpp:858
#36 0x0000000000202908 in main (argc=<optimized out>, argv=<optimized out>) at /home/lantw44/gnome/source/gjs/gjs/console.cpp:366
Expected behaviour
The call to glibtop_init
should succeed. It should not throw an exception. It should not crash when calling the function twice.