GC of EDataServer.SourceRegistry causes a crash on GNOME 42
Referencing EDataServer.SourceRegistry
in code causes a crash when application window gets closed on GNOME 42. Simple reproducer:
imports.gi.versions['Gtk'] = '4.0';
const {EDataServer, Gtk} = imports.gi;
const app = new Gtk.Application({application_id: 'com.example.GtkApplication'});
app.connect('activate', () => {
const win = new Gtk.ApplicationWindow({application: app});
const btn = new Gtk.Button({label: 'Close the window and cause the crash'});
const registry = EDataServer.SourceRegistry.new_sync(null);
log(registry);
btn.connect('clicked', () => {
win.close();
});
win.set_child(btn);
win.present();
});
app.run([]);
Stack trace (updated with debug symbols):
#0 0x0000000000000000 in ()
#1 0x00007ffff7c6a05f in g_main_dispatch (context=0x4449e0) at ../glib/gmain.c:3381
#2 g_main_context_dispatch (context=0x4449e0) at ../glib/gmain.c:4099
#3 0x00007ffff7cbf2a8 in g_main_context_iterate.constprop.0
(context=context@entry=0x4449e0, block=block@entry=0, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4175
#4 0x00007ffff7c67853 in g_main_context_iteration
(context=0x4449e0, may_block=may_block@entry=0) at ../glib/gmain.c:4240
#5 0x00007ffff06522fa in source_registry_dispose (object=0x4471d0)
at /usr/src/debug/evolution-data-server-3.42.4-1.fc35.x86_64/src/libedataserver/e-source-registry.c:1354
#6 0x00007ffff7bd9bc4 in g_object_unref (_object=<optimized out>) at ../gobject/gobject.c:3540
#7 g_object_unref (_object=0x4471d0) at ../gobject/gobject.c:3470
#8 0x00007ffff7e08611 in GjsAutoPointer<_GObject, void, &g_object_unref, &g_object_ref>::reset(_GObject*) (this=0x7fffffffcfe8, ptr=0x0) at ../gjs/jsapi-util.h:162
#9 0x00007ffff7e03d9b in GjsAutoPointer<_GObject, void, &g_object_unref, &g_object_ref>::~GjsAutoPointer() (this=0x7fffffffcfe8, __in_chrg=<optimized out>) at ../gjs/jsapi-util.h:171
#10 0x00007ffff7e01b4a in GjsSmartPointer<_GObject>::~GjsSmartPointer()
(this=0x7fffffffcfe8, __in_chrg=<optimized out>) at ../gjs/jsapi-util.h:348
#11 0x00007ffff7df84aa in ObjectInstance::release_native_object() (this=0x7fffe4039410)
at ../gi/object.cpp:1521
#12 0x00007ffff7df9109 in ObjectInstance::disassociate_js_gobject() (this=0x7fffe4039410)
at ../gi/object.cpp:1748
#13 0x00007ffff7e16e57 in std::__invoke_impl<void, void (ObjectInstance::* const&)(), ObjectInstance*>(std::__invoke_memfun_deref, void (ObjectInstance::* const&)(), ObjectInstance*&&)
(__f=@0x7fffffffd260: (void (ObjectInstance::*)(ObjectInstance * const)) 0x7ffff7df8fce <ObjectInstance::disassociate_js_gobject()>, __t=@0x7fffffffd160: 0x7fffe4039410)
at /usr/include/c++/11/bits/invoke.h:74
#14 0x00007ffff7e163d3 in std::__invoke<void (ObjectInstance::* const&)(), ObjectInstance*>(void (ObjectInstance::* const&)(), ObjectInstance*&&)
(__fn=@0x7fffffffd260: (void (ObjectInstance::*)(ObjectInstance * const)) 0x7ffff7df8fce <ObjectInstance::disassociate_js_gobject()>) at /usr/include/c++/11/bits/invoke.h:96
#15 0x00007ffff7e14c20 in std::_Mem_fn_base<void (ObjectInstance::*)(), true>::operator()<ObjectInstance*>(ObjectInstance*&&) const (this=0x7fffffffd260) at /usr/include/c++/11/functional:131
#16 0x00007ffff7e11e97 in std::__invoke_impl<void, std::_Mem_fn<void (ObjectInstance::*)()>&, ObjectInstance*>(std::__invoke_other, std::_Mem_fn<void (ObjectInstance::*)()>&, ObjectInstance*&&) (__f=...) at /usr/include/c++/11/bits/invoke.h:61
#17 0x00007ffff7e0d903 in std::__invoke_r<void, std::_Mem_fn<void (ObjectInstance::*)()>&, ObjectInstance*>(std::_Mem_fn<void (ObjectInstance::*)()>&, ObjectInstance*&&) (__fn=...)
at /usr/include/c++/11/bits/invoke.h:111
#18 0x00007ffff7e087d9 in std::_Function_handler<void (ObjectInstance*), std::_Mem_fn<void (ObjectInstance::*)()> >::_M_invoke(std::_Any_data const&, ObjectInstance*&&)
(__functor=..., __args#0=@0x7fffffffd160: 0x7fffe4039410)
at /usr/include/c++/11/bits/std_function.h:290
#19 0x00007ffff7e0398f in std::function<void (ObjectInstance*)>::operator()(ObjectInstance*) const (this=0x7fffffffd260, __args#0=0x7fffe4039410)
at /usr/include/c++/11/bits/std_function.h:590
#20 0x00007ffff7df7dee in operator()(ObjectInstance*) const
(__closure=0x7fffffffd240, link=0x7fffe4039410) at ../gi/object.cpp:1302
#21 0x00007ffff7dfff65 in __gnu_cxx::__ops::_Iter_pred<ObjectInstance::remove_wrapped_gobjects_if(const Predicate&, const Action&)::<lambda(ObjectInstance*)> >::operator()<__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*> > >(__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >)
(this=0x7fffffffd240, __it=0x7fffe4039410) at /usr/include/c++/11/bits/predefined_ops.h:318
#22 0x00007ffff7e00122 in std::__find_if<__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*> >, __gnu_cxx::__ops::_Iter_pred<ObjectInstance::remove_wrapped_gobjects_if(const Predicate&, const Action&)::<lambda(ObjectInstance*)> > >(__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >, __gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >, __gnu_cxx::__ops::_Iter_pred<ObjectInstance::remove_wrapped_gobjects_if(const Predicate&, const Action&)::<lambda(ObjectInstance*)> >, std::random_access_iterator_tag)
(__first=0x7fffe4039410, __last=0x0, __pred=...)
at /usr/include/c++/11/bits/stl_algobase.h:2099
#23 0x00007ffff7dfff00 in std::__find_if<__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*> >, __gnu_cxx::__ops::_Iter_pred<ObjectInstance::remove_wrapped_gobjects_if(const Predicate&, const Action&)::<lambda(ObjectInstance*)> > >(__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >, __gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >, __gnu_cxx::__ops::_Iter_pred<ObjectInstance::remove_wrapped_gobjects_if(const Predicate&, const Action&)::<lambda(ObjectInstance*)> >) (__first=0x7fffe4039410, __last=0x0, __pred=...)
at /usr/include/c++/11/bits/stl_algobase.h:2114
#24 0x00007ffff7dff389 in std::__remove_if<__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*> >, __gnu_cxx::__ops::_Iter_pred<ObjectInstance::remove_wrapped_gobjects_if(const Predicate&, const Action&)::<lambda(ObjectInstance*)> > >(__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >, __gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >, __gnu_cxx::__ops::_Iter_pred<ObjectInstance::remove_wrapped_gobjects_if(const Predicate&, const Action&)::<lambda(ObjectInstance*)> >) (__first=0x7fffe4039410, __last=0x0, __pred=...)
at /usr/include/c++/11/bits/stl_algo.h:816
#25 0x00007ffff7dfeade in std::remove_if<__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*> >, ObjectInstance::remove_wrapped_gobjects_if(const Predicate&, const Action&)::<lambda(ObjectInstance*)> >(__gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >, __gnu_cxx::__normal_iterator<ObjectInstance**, std::vector<ObjectInstance*, std::allocator<ObjectInstance*> > >, struct {...})
(__first=0x7fffe4039410, __last=0x0, __pred=...) at /usr/include/c++/11/bits/stl_algo.h:894
#26 0x00007ffff7df7ebf in ObjectInstance::remove_wrapped_gobjects_if(std::function<bool (ObjectInstance*)> const&, std::function<void (ObjectInstance*)> const&) (predicate=..., action=...)
at ../gi/object.cpp:1298
#27 0x00007ffff7df8977 in ObjectInstance::update_heap_wrapper_weak_pointers(JSContext*, JS::Compartment*, void*) () at ../gi/object.cpp:1595
#28 0x00007ffff68027ed in js::gc::GCRuntime::callWeakPointerCompartmentCallbacks(JS::Compartment*) const (this=0x460768, comp=0x4d7410)
at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:2045
#29 js::gc::GCRuntime::beginSweepingSweepGroup(JSFreeOp*, js::SliceBudget&)
(this=<optimized out>, fop=<optimized out>, budget=<optimized out>)
at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:5758
#30 0x00007ffff6845be1 in sweepaction::SweepActionSequence::run(js::gc::SweepAction::Args&)
(this=0x478840, args=...) at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:6414
#31 0x00007ffff6835175 in sweepaction::SweepActionForEach<js::gc::SweepGroupsIter, JSRuntime*>::run(js::gc::SweepAction::Args&) (this=0x478900, args=...)
at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:6449
#32 0x00007ffff680701f in js::gc::GCRuntime::performSweepActions(js::SliceBudget&)
(this=this@entry=0x460768, budget=...)
at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:6581
#33 0x00007ffff680cc16 in js::gc::GCRuntime::incrementalSlice(js::SliceBudget&, mozilla::Maybe<JS::GCOptions> const&, JS::GCReason)
(this=this@entry=0x460768, budget=..., options=..., reason=<optimized out>,
reason@entry=JS::GCReason::COMPONENT_UTILS)
at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:7240
#34 0x00007ffff680f753 in js::gc::GCRuntime::gcCycle(bool, js::SliceBudget const&, mozilla::Maybe<JS::GCOptions> const&, JS::GCReason)
(this=this@entry=0x460768, nonincrementalByAPI=true, budgetArg=<optimized out>, options=..., reason=reason@entry=JS::GCReason::COMPONENT_UTILS)
at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:7656
#35 0x00007ffff681077d in js::gc::GCRuntime::collect(bool, js::SliceBudget const&, mozilla::Maybe<JS::GCOptions> const&, JS::GCReason)
(this=0x460768, nonincrementalByAPI=true, budget=..., optionsArg=..., reason=JS::GCReason::COMPONENT_UTILS) at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:7865
#36 0x00007ffff67cc9c0 in js::gc::GCRuntime::gc(JS::GCOptions, JS::GCReason)
(this=0x430e60, options=<optimized out>, reason=4294954480)
at /var/home/ptomato/workspace/mozjs/js/src/gc/GC.cpp:7945
#37 0x00007ffff7e33c37 in GjsContextPrivate::dispose() (this=0x45f080)
at ../gjs/context.cpp:440
#38 0x00007ffff7e339d3 in gjs_context_dispose(GObject*) (object=0x45f210)
at ../gjs/context.cpp:397
#39 0x00007ffff7bd9bc4 in g_object_unref (_object=<optimized out>) at ../gobject/gobject.c:3540
#40 g_object_unref (_object=0x45f210) at ../gobject/gobject.c:3470
#41 0x0000000000403689 in main(int, char**) (argc=2, argv=0x7fffffffe008)
at ../gjs/console.cpp:398
Tested on latest GNOME OS Nightly.
Edited by Philip Chimento