gjs crashes when failing to import a GI repo
While porting GNOME 3.36.x on s390x for SUSE Linux Enterprise 15 SP2, we bumped into the following crash in gnome-shell (gjs 1.58.3 / mozjs60 60.9.0 / mutter 3.34.1 / gnome-shell 3.34.1):
Core was generated by `/usr/bin/gnome-shell'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 gjs_debug_flat_string (fstr=<optimized out>) at gjs/jsapi-util-string.cpp:395
395 char16_t c = chars[ix];
[Current thread is 1 (Thread 0x3ff985451c0 (LWP 14321))]
(gdb) bt
#0 gjs_debug_flat_string (fstr=<optimized out>) at gjs/jsapi-util-string.cpp:395
#1 0x000003ff97391e6a in gjs_debug_id[abi:cxx11](jsid) (id=...) at gjs/jsapi-util-string.cpp:513
#2 0x000003ff9738a1c4 in throw_property_lookup_error (cx=cx@entry=0x2aa3b639a70, obj=..., obj@entry=..., description=description@entry=0x3ff973bf9fe "GI repository object", property_name=...,
property_name@entry=..., reason=reason@entry=0x3ff973c3968 "it was not an object") at gjs/jsapi-util.cpp:54
#3 0x000003ff9738a780 in gjs_object_require_property (cx=cx@entry=0x2aa3b639a70, obj=obj@entry=..., description=description@entry=0x3ff973bf9fe "GI repository object", property_name=..., value=...,
value@entry=...) at gjs/jsapi-util.cpp:158
#4 0x000003ff9736d63a in lookup_override_function (function=..., ns_name=..., cx=0x2aa3b639a70) at gi/repo.cpp:604
#5 resolve_namespace_object (ns_id=..., repo_obj=..., context=0x2aa3b639a70) at gi/repo.cpp:143
#6 repo_resolve (context=0x2aa3b639a70, obj=..., id=..., resolved=0x3fff377d0b0) at gi/repo.cpp:202
#7 0x000003ff93e88666 in js::CallResolveOp (recursedp=<synthetic pointer>, propp=..., id=..., obj=..., cx=0x2aa3b639a70) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject-inl.h:715
#8 js::LookupOwnPropertyInline<(js::AllowGC)1> (donep=<synthetic pointer>, propp=..., id=..., obj=..., cx=<optimized out>) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject-inl.h:782
#9 NativeGetPropertyInline<(js::AllowGC)1> (vp=..., nameLookup=NotNameLookup, id=..., receiver=..., obj=..., cx=0x2aa3b639a70) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject.cpp:2251
#10 js::NativeGetProperty (cx=0x2aa3b639a70, obj=..., receiver=..., id=..., vp=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject.cpp:2299
#11 0x000003ff93b9f5d6 in js::GetProperty (cx=0x2aa3b639a70, v=..., name=..., vp=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject.h:1589
#12 0x000003ff93bad36c in Interpret (cx=0x2aa3b639a70, state=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/Interpreter.cpp:203
#13 0x000003ff93bb86aa in js::RunScript (cx=0x2aa3b639a70, state=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/Interpreter.cpp:385
#14 0x000003ff93bbaade in js::Execute (cx=cx@entry=0x2aa3b639a70, script=script@entry=..., envChainArg=..., rval=0x3fff377dbd0) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/Interpreter.cpp:654
#15 0x000003ff93d66eae in Evaluate (cx=0x2aa3b639a70, scopeKind=<optimized out>, env=..., optionsArg=..., srcBuf=..., rval=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/jsapi.cpp:4190
#16 0x000003ff93d69144 in JS::Evaluate (cx=cx@entry=0x2aa3b639a70, envChain=..., optionsArg=..., srcBuf=..., rval=..., rval@entry=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/jsapi.cpp:4202
#17 0x000003ff9739270a in GjsModule::evaluate_import (this=this@entry=0x2aa3ba14e10, cx=cx@entry=0x2aa3b639a70, module=module@entry=...,
script=script@entry=0x2aa3bbe8a10 "// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-\n/* exported init */\n\nconst Config = imports.misc.config;\n\nimports.gi.versions.Clutter = Config.LIBMUTTER_API_VERSION;\nimports.gi.versions"..., script_len=script_len@entry=10288, filename=0x2aa3b9e8950 "resource:///org/gnome/shell/ui/environment.js") at gjs/module.cpp:118
#18 0x000003ff973921ea in GjsModule::import_file (file=0x2aa3ba45760, module=..., cx=0x2aa3b639a70, this=0x2aa3ba14e10) at gjs/module.cpp:148
#19 GjsModule::import (file=0x2aa3ba45760, name=0x2aa3b6b8d90 "environment", id=..., importer=..., cx=0x2aa3b639a70) at gjs/module.cpp:230
#20 gjs_module_import (cx=cx@entry=0x2aa3b639a70, importer=importer@entry=..., id=..., id@entry=..., name=name@entry=0x2aa3b6b8d90 "environment", file=file@entry=0x2aa3ba45760) at gjs/module.cpp:260
#21 0x000003ff97388082 in import_file_on_module (file=0x2aa3ba45760, name=0x2aa3b6b8d90 "environment", id=..., obj=..., context=0x2aa3b639a70) at gjs/importer.cpp:458
#22 do_import (id=..., priv=<optimized out>, obj=..., context=0x2aa3b639a70) at gjs/importer.cpp:593
#23 importer_resolve (context=0x2aa3b639a70, obj=..., id=..., resolved=0x3fff377e180) at gjs/importer.cpp:790
#24 0x000003ff93e88666 in js::CallResolveOp (recursedp=<synthetic pointer>, propp=..., id=..., obj=..., cx=0x2aa3b639a70) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject-inl.h:715
#25 js::LookupOwnPropertyInline<(js::AllowGC)1> (donep=<synthetic pointer>, propp=..., id=..., obj=..., cx=<optimized out>) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject-inl.h:782
#26 NativeGetPropertyInline<(js::AllowGC)1> (vp=..., nameLookup=NotNameLookup, id=..., receiver=..., obj=..., cx=0x2aa3b639a70) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject.cpp:2251
#27 js::NativeGetProperty (cx=0x2aa3b639a70, obj=..., receiver=..., id=..., vp=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject.cpp:2299
#28 0x000003ff93b9f5d6 in js::GetProperty (cx=0x2aa3b639a70, v=..., name=..., vp=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/NativeObject.h:1589
#29 0x000003ff93bad36c in Interpret (cx=0x2aa3b639a70, state=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/Interpreter.cpp:203
#30 0x000003ff93bb86aa in js::RunScript (cx=0x2aa3b639a70, state=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/Interpreter.cpp:385
#31 0x000003ff93bbaade in js::Execute (cx=cx@entry=0x2aa3b639a70, script=script@entry=..., envChainArg=..., rval=0x3fff377ef20) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/vm/Interpreter.cpp:654
#32 0x000003ff93d66eae in Evaluate (cx=0x2aa3b639a70, scopeKind=<optimized out>, env=..., optionsArg=..., srcBuf=..., rval=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/jsapi.cpp:4190
#33 0x000003ff93d69144 in JS::Evaluate (cx=0x2aa3b639a70, envChain=..., optionsArg=..., srcBuf=..., rval=..., rval@entry=...) at /usr/src/debug/mozjs60-60.9.0-1.2.s390x/js/src/jsapi.cpp:4202
#34 0x000003ff9737cc0e in GjsContextPrivate::eval_with_scope (this=this@entry=0x2aa3b5e4300, scope_object=scope_object@entry=...,
script=script@entry=0x3ff982bde24 "imports.ui.environment.init();imports.ui.main.start();", script_len=script_len@entry=-1, filename=filename@entry=0x3ff982bde1c "<main>", retval=...)
at gjs/context.cpp:1009
#35 0x000003ff9737cfce in GjsContextPrivate::eval (this=0x2aa3b5e4300, script=script@entry=0x3ff982bde24 "imports.ui.environment.init();imports.ui.main.start();", script_len=script_len@entry=-1,
filename=filename@entry=0x3ff982bde1c "<main>", exit_status_p=0x3fff377f0cc, error=0x3fff377f0d0) at gjs/context.cpp:882
#36 0x000003ff9737d390 in gjs_context_eval (js_context=js_context@entry=0x2aa3b5e43f0, script=script@entry=0x3ff982bde24 "imports.ui.environment.init();imports.ui.main.start();",
script_len=script_len@entry=-1, filename=filename@entry=0x3ff982bde1c "<main>", exit_status_p=exit_status_p@entry=0x3fff377f0cc, error=0x3fff377f0d0) at gjs/context.cpp:862
#37 0x000003ff982a3fe4 in gnome_shell_plugin_start (plugin=<optimized out>) at ../src/gnome-shell-plugin.c:127
#38 0x000003ff96f32a5e in meta_plugin_manager_new (compositor=compositor@entry=0x2aa39fc4d10) at ../src/compositor/meta-plugin-manager.c:113
#39 0x000003ff96f2ab50 in meta_compositor_manage (compositor=0x2aa39fc4d10) at ../src/compositor/compositor.c:573
#40 0x000003ff96f49c62 in enable_compositor (display=0x2aa3b8be010) at ../src/core/display.c:595
#41 meta_display_open () at ../src/core/display.c:812
#42 0x000003ff96f54bd0 in meta_run () at ../src/core/main.c:673
#43 0x000002aa38d82d08 in main (argc=<optimized out>, argv=<optimized out>) at ../src/main.c:552
This is probably not the real cause of the crash but it prevents to display the proper error message in the logs.
Edited by Frédéric Crozat