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 747506 - Garbage collector complains during shutdown
Garbage collector complains during shutdown
Status: RESOLVED FIXED
Product: gnome-documents
Classification: Core
Component: general
3.16.x
Other Linux
: Normal normal
: ---
Assigned To: GNOME documents maintainer(s)
GNOME documents maintainer(s)
: 789429 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-04-08 13:08 UTC by Debarshi Ray
Modified: 2018-08-16 16:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
embed: Silence the garbage collector (894 bytes, patch)
2015-04-08 18:16 UTC, Debarshi Ray
none Details | Review
embed: Silence the garbage collector (935 bytes, patch)
2015-04-08 18:23 UTC, Debarshi Ray
none Details | Review
view: Remove unused signal handler IDs (1.59 KB, patch)
2015-04-10 11:45 UTC, Debarshi Ray
committed Details | Review
view: Disconnect from global objects when the widget is destroyed (2.21 KB, patch)
2015-04-10 11:46 UTC, Debarshi Ray
committed Details | Review
mainToolbar: Disconnect from DocumentManager when destroyed (2.14 KB, patch)
2015-04-10 11:46 UTC, Debarshi Ray
committed Details | Review
mainToolbar: Clean up (1.34 KB, patch)
2015-04-10 11:47 UTC, Debarshi Ray
committed Details | Review
preview: Clean up (1.25 KB, patch)
2015-04-10 13:15 UTC, Debarshi Ray
committed Details | Review
preview: Disconnect from global objects when the widget is destroyed (4.69 KB, patch)
2015-04-10 13:15 UTC, Debarshi Ray
committed Details | Review
embed: explicitly destroy the titlebar (1011 bytes, patch)
2015-07-29 00:24 UTC, Alessandro Bono
reviewed Details | Review
preview, selections: Be nice to the garbage collector during shutdown (5.36 KB, patch)
2018-08-14 17:21 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2015-04-08 13:08:52 UTC
Steps to reproduce:
1) start application from console
2) toggle the search button
3) close the main window
4) wait for the inactivity-timeout of 12s to expire

This shows up in the console:

(gnome-documents:21023): Gjs-CRITICAL **: Attempting to call back into JSAPI during the sweeping phase of GC. This is most likely caused by not destroying a Clutter actor or Gtk+ widget with ::destroy signals connected, but can also be caused by using the destroy() or dispose() vfuncs. Because it would crash the application, it has been blocked and the JS callback not invoked.

(gnome-documents:21023): Gjs-CRITICAL **: Attempting to call back into JSAPI during the sweeping phase of GC. This is most likely caused by not destroying a Clutter actor or Gtk+ widget with ::destroy signals connected, but can also be caused by using the destroy() or dispose() vfuncs. Because it would crash the application, it has been blocked and the JS callback not invoked.

(gnome-documents:21023): Gjs-CRITICAL **: The offending signal was destroy on GtkBox 0x29e3510.

(gnome-documents:21023): Gjs-CRITICAL **: Attempting to call back into JSAPI during the sweeping phase of GC. This is most likely caused by not destroying a Clutter actor or Gtk+ widget with ::destroy signals connected, but can also be caused by using the destroy() or dispose() vfuncs. Because it would crash the application, it has been blocked and the JS callback not invoked.

(gnome-documents:21023): Gjs-CRITICAL **: The offending signal was destroy on GtkSearchBar 0x2473590.

(gnome-documents:21023): Gjs-CRITICAL **: Attempting to call back into JSAPI during the sweeping phase of GC. This is most likely caused by not destroying a Clutter actor or Gtk+ widget with ::destroy signals connected, but can also be caused by using the destroy() or dispose() vfuncs. Because it would crash the application, it has been blocked and the JS callback not invoked.

(gnome-documents:21023): Gjs-CRITICAL **: The offending signal was destroy on GdTaggedEntry 0x292cc10.
Comment 1 Debarshi Ray 2015-04-08 18:16:25 UTC
Created attachment 301155 [details] [review]
embed: Silence the garbage collector

I don't know what is going on here, but it looks similar to the issue in commit 53fe30610
Comment 2 Debarshi Ray 2015-04-08 18:23:39 UTC
Created attachment 301156 [details] [review]
embed: Silence the garbage collector
Comment 3 Debarshi Ray 2015-04-08 18:32:53 UTC
I am still getting one of these with the same set of steps:

(gnome-documents:22697): Gjs-CRITICAL **: Attempting to call back into JSAPI during the sweeping phase of GC. This is most likely caused by not destroying a Clutter actor or Gtk+ widget with ::destroy signals connected, but can also be caused by using the destroy() or dispose() vfuncs. Because it would crash the application, it has been blocked and the JS callback not invoked.

And I have this:

$ G_DEBUG=fatal-criticals DOCUMENTS_RUN_DEBUG=1 /opt/bin/gnome-documents
(gdb) run
...
(gdb) bt
  • #0 g_logv
    at gmessages.c line 1046
  • #1 g_log
    at gmessages.c line 1079
  • #2 gjs_callback_closure
    at gi/function.cpp line 195
  • #3 ffi_closure_unix64_inner
    from /lib64/libffi.so.6
  • #4 ffi_closure_unix64
    from /lib64/libffi.so.6
  • #5 g_application_impl_stop_primary
    at gapplicationimpl-dbus.c line 458
  • #6 g_application_impl_destroy
    at gapplicationimpl-dbus.c line 504
  • #7 g_application_finalize
    at gapplication.c line 1230
  • #8 g_object_unref
    at gobject.c line 3174
  • #9 release_native_object
    at gi/object.cpp line 1107
  • #10 object_instance_finalize
    at gi/object.cpp line 1428
  • #11 finalize
    at /usr/src/debug/mozjs-24.2.0/js/src/jsobjinlines.h line 213
  • #12 finalize<JSObject>
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 331
  • #14 FinalizeArenas
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 432
  • #15 finalizeNow
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 1306
  • #16 js::gc::ArenaLists::queueObjectsForSweep
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 1402
  • #17 BeginSweepingZoneGroup
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 3677
  • #18 BeginSweepPhase
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 3761
  • #20 GCCycle(JSRuntime *, bool, int64_t, js::JSGCInvocationKind, enum JS::gcreason::Reason)
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 4422
  • #21 Collect(JSRuntime *, bool, int64_t, js::JSGCInvocationKind, enum JS::gcreason::Reason)
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 4558
  • #22 Collect
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 4581
  • #23 js::GC
    at /usr/src/debug/mozjs-24.2.0/js/src/jsgc.cpp line 4580
  • #24 js::DestroyContext
    at /usr/src/debug/mozjs-24.2.0/js/src/jscntxt.cpp line 392
  • #25 JS_DestroyContext
    at /usr/src/debug/mozjs-24.2.0/js/src/jsapi.cpp line 1240
  • #26 gjs_context_dispose
    at gjs/context.cpp line 367
  • #27 g_object_unref
    at gobject.c line 3137
  • #28 main
    at gjs/console.cpp line 154

I don't know if there are smarter ways to debug this, so any suggestions are welcome.
Comment 4 Debarshi Ray 2015-04-10 11:42:17 UTC
I finally read gjs/modules/signals.js and found a few places where our signal handler management is broken. It can explain this bug and also why we had to explicitly destroy the toolbars in commit 53fe30610
Comment 5 Debarshi Ray 2015-04-10 11:45:50 UTC
Created attachment 301276 [details] [review]
view: Remove unused signal handler IDs
Comment 6 Debarshi Ray 2015-04-10 11:46:17 UTC
Created attachment 301277 [details] [review]
view: Disconnect from global objects when the widget is destroyed
Comment 7 Debarshi Ray 2015-04-10 11:46:42 UTC
Created attachment 301278 [details] [review]
mainToolbar: Disconnect from DocumentManager when destroyed
Comment 8 Debarshi Ray 2015-04-10 11:47:09 UTC
Created attachment 301279 [details] [review]
mainToolbar: Clean up
Comment 9 Debarshi Ray 2015-04-10 13:15:05 UTC
Created attachment 301284 [details] [review]
preview: Clean up
Comment 10 Debarshi Ray 2015-04-10 13:15:37 UTC
Created attachment 301285 [details] [review]
preview: Disconnect from global objects when the widget is destroyed
Comment 11 Cosimo Cecchi 2015-04-10 17:34:09 UTC
Review of attachment 301276 [details] [review]:

Looks good
Comment 12 Cosimo Cecchi 2015-04-10 17:34:46 UTC
Review of attachment 301277 [details] [review]:

Looks good
Comment 13 Cosimo Cecchi 2015-04-10 17:35:22 UTC
Review of attachment 301278 [details] [review]:

OK
Comment 14 Cosimo Cecchi 2015-04-10 17:35:41 UTC
Review of attachment 301279 [details] [review]:

Sure
Comment 15 Cosimo Cecchi 2015-04-10 17:36:01 UTC
Review of attachment 301284 [details] [review]:

Yep
Comment 16 Cosimo Cecchi 2015-04-10 17:36:36 UTC
Review of attachment 301285 [details] [review]:

OK
Comment 17 Cosimo Cecchi 2015-04-10 17:37:21 UTC
Thanks for tracking these down, Debarshi!
Comment 18 Debarshi Ray 2015-04-10 17:56:09 UTC
These still don't address the CRITICALS from gjs. Needs further investigation.
Comment 19 Alessandro Bono 2015-07-29 00:24:25 UTC
Created attachment 308348 [details] [review]
embed: explicitly destroy the titlebar

since GtkApplicationWindow when closed doesn't destroy the titlebar,
do it  explicitly
Comment 20 Debarshi Ray 2015-07-29 16:01:02 UTC
Review of attachment 308348 [details] [review]:

::: src/embed.js
@@ +165,3 @@
+            function() {
+                this._titlebar.destroy();
+            }));

This is basically the same thing as attachment 301156 [details] [review]

The problem is that it still leaves behind one of the CRITICALs, and it might be the root cause behind the titlebar not getting destroyed. However, I failed to track it down.

I am torn between committing this (hack?) to silence the bulk of the CRITICALs and finding the root cause behind this. Cosimo?
Comment 21 Debarshi Ray 2015-08-06 15:35:26 UTC
Review of attachment 308348 [details] [review]:

I wonder if commit b941dcc9199 is of any help here.
Comment 22 Debarshi Ray 2017-10-25 06:08:51 UTC
*** Bug 789429 has been marked as a duplicate of this bug. ***
Comment 23 Debarshi Ray 2018-08-14 17:09:27 UTC
Another duplicate:
https://gitlab.gnome.org/GNOME/gnome-documents/issues/9
Comment 24 Debarshi Ray 2018-08-14 17:21:25 UTC
Created attachment 373337 [details] [review]
preview, selections: Be nice to the garbage collector during shutdown
Comment 25 Debarshi Ray 2018-08-16 16:02:11 UTC
Comment on attachment 373337 [details] [review]
preview, selections: Be nice to the garbage collector during shutdown

I pushed this to master, so that we can have it in the 3.29.91 tarball. My discussions with Philip Chimento confirm that connecting to GtkWidget::destroy is fine, but vfunc_destroy is not, as evidenced by:
  https://gitlab.gnome.org/GNOME/gnome-shell/commit/98b50fd9423e57

However, neither of us have been able to explain exactly why that might be.

In the meantime, while we figure that out, this patch seems to address a real user-visible problem. With current versions of GJS (>= 1.52), gnome-documents crashes instead of just logging CRITICALs on shutdown, and this change fixes that.