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 780216 - Possible deadlock in GtkSourceFileSaver
Possible deadlock in GtkSourceFileSaver
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: File loading and saving
3.23.x
Other Linux
: Normal critical
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-17 18:10 UTC by Georges Basile Stavracas Neto
Modified: 2017-03-19 09:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
workaround deadlock by preregistering types (1.27 KB, patch)
2017-03-18 10:05 UTC, Christian Hergert
needs-work Details | Review
workaround deadlocks in type initialization (1.80 KB, patch)
2017-03-18 10:18 UTC, Christian Hergert
committed Details | Review

Description Georges Basile Stavracas Neto 2017-03-17 18:10:25 UTC
I frequently get stuck on this appearent deadlock. See the backtrace below: 

sys:1: Warning: g_object_new_valist: object class 'GtkSourceBufferInputStream' has no property named 'newline-type'
[Thread 0x7fffcc9ea700 (LWP 23599) exited]
[Thread 0x7fffb6df7700 (LWP 23541) exited]
[Thread 0x7fffb7fff700 (LWP 23527) exited]
^C
Thread 1 "lt-gnome-builde" received signal SIGINT, Interrupt.
0x00007fffeeb55889 in syscall () from /usr/lib/libc.so.6
(gdb) bt
  • #0 syscall
    from /usr/lib/libc.so.6
  • #1 g_cond_wait
    at gthread-posix.c line 1395
  • #2 g_once_init_enter
    at gthread.c line 665
  • #3 g_param_spec_get_default_value
    at gparam.c line 1556
  • #4 g_object_new_internal
    at gobject.c line 1815
  • #5 g_object_new_valist
    at gobject.c line 2042
  • #6 g_object_new
    at gobject.c line 1626
  • #7 _gtk_source_buffer_input_stream_new
    at gtksourcebufferinputstream.c line 477
  • #8 gtk_source_file_saver_save_async
    at gtksourcefilesaver.c line 1434
  • #9 ide_buffer_manager_save_file__load_settings_cb
    at buffers/ide-buffer-manager.c line 1082
  • #10 g_task_return_now
    at gtask.c line 1145
  • #11 complete_in_idle_cb
    at gtask.c line 1159
  • #12 g_main_dispatch
    at gmain.c line 3203
  • #13 g_main_context_dispatch
    at gmain.c line 3856
  • #14 g_main_context_iterate
    at gmain.c line 3929
  • #15 g_main_context_iteration
    at gmain.c line 3990
  • #16 g_application_run
    at gapplication.c line 2381
  • #17 main
    at main.c line 118

Comment 1 Christian Hergert 2017-03-17 20:28:04 UTC
This is probably related to bug 674885.

However, since GtkSourceBufferInputStream is a private type, I don't exactly have access to be able to pre-register the type at startup (which usually works around the deadlock type initialization issue).

One other possible workaround could be to synchronously save something at startup to an ephemeral file to force the type initialization.

Another possibility is that this is just a memory corruption issue.
Comment 2 Christian Hergert 2017-03-17 20:43:51 UTC
I've added a patch ontop of gtksourceview in our Builder.flatpak and notified upstream of our interest to have that done. If it's a memory corruption issue causing GOnce to break, it wont help. But if it is indeed related to similar deadlock issues, it might.
Comment 3 Sébastien Wilmet 2017-03-18 09:35:34 UTC
Let's move this bug to GtkSourceView.
Comment 4 Sébastien Wilmet 2017-03-18 10:02:58 UTC
(In reply to Georges Basile Stavracas Neto from comment #0)
> I frequently get stuck on this appearent deadlock.

So the application freezes completely?

I think it's fine to add:

g_type_ensure (GTK_SOURCE_TYPE_BUFFER_INPUT_STREAM);

in gtk_source_file_saver_class_init().
Comment 5 Christian Hergert 2017-03-18 10:05:53 UTC
Created attachment 348218 [details] [review]
workaround deadlock by preregistering types
Comment 6 Sébastien Wilmet 2017-03-18 10:09:00 UTC
(In reply to Georges Basile Stavracas Neto from comment #0)
> sys:1: Warning: g_object_new_valist: object class
> 'GtkSourceBufferInputStream' has no property named 'newline-type'

This warning is strange because GtkSourceBufferInputStream *has* a property named 'newline-type'. If it deadlocks, why doesn't it deadlock *before* issuing that warning?

Anyway, the g_type_ensure() would be harmless, and there are chances that it will solve the bug.
Comment 7 Christian Hergert 2017-03-18 10:11:01 UTC
The problem from last time I looked into this was in getting the default value for it. I think it could find the pspec in the param spec pool, but something else (getting access to the default value via the enum vtable or something) was the issue.
Comment 8 Sébastien Wilmet 2017-03-18 10:11:48 UTC
Review of attachment 348218 [details] [review]:

It needs comments with a link to this bug, and also a link to https://bugzilla.gnome.org/show_bug.cgi?id=674885, explaining that it's a workaround.

The master branch is not frozen, but the gnome-3-24 branch is (hard code freeze). So on gnome-3-24 it'll need to be pushed after the freeze.
Comment 9 Christian Hergert 2017-03-18 10:18:13 UTC
Created attachment 348219 [details] [review]
workaround deadlocks in type initialization
Comment 10 Sébastien Wilmet 2017-03-18 10:31:42 UTC
Review of attachment 348219 [details] [review]:

Thanks.
Comment 11 Christian Hergert 2017-03-18 10:32:43 UTC
Comment on attachment 348219 [details] [review]
workaround deadlocks in type initialization

Attachment 348219 [details] pushed as 924fee3 - workaround deadlocks in type initialization
Comment 12 Sébastien Wilmet 2017-03-19 09:45:53 UTC
And now cherry-picked on gnome-3-24:
commit fb70858b230ebc60595dca103823f8c772ea974b