Bug 163105 - [GTK] gobject-introspection on package build with webkit2gtk fails without active X session
Summary: [GTK] gobject-introspection on package build with webkit2gtk fails without ac...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-07 03:41 PDT by Alberto Garcia
Modified: 2016-10-17 02:09 PDT (History)
4 users (show)

See Also:


Attachments
Patch (1.78 KB, patch)
2016-10-17 01:23 PDT, Alberto Garcia
cgarcia: review+
cgarcia: commit-queue-
Details | Formatted Diff | Diff
Patch #2 (2.36 KB, patch)
2016-10-17 01:43 PDT, Alberto Garcia
cgarcia: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alberto Garcia 2016-10-07 03:41:17 PDT
I'm hesitant to consider this a bug in webkit, but here it goes in case you have any thoughts:

Packages built with webkit2gtk fail during the gobject-introspection phase if there's no active X session.

This was reported in the Liferea package:

https://github.com/lwindolf/liferea/issues/398

It seems that webkit_settings_new() ends up calling XCompositeQueryExtension() (which fails), and this might have been caused by r204013 (Move the redirected XComposite window to the web process), the fix for bug 160389

Possible solutions:

- Have a working X session :)
- Use xfvb-run
- Set WEBKIT_DISABLE_COMPOSITING_MODE=1 while running g-ir-scanner
Comment 1 Carlos Garcia Campos 2016-10-15 01:41:33 PDT
Disabling AC mode sounds like the easiest solution in the short term (until this options disappears if we ever remove the non Ac support). In the long term we might have support for headless environments, or better handle the case where there's no display.
Comment 2 Alberto Garcia 2016-10-16 02:30:21 PDT
I told the Liferea maintainer to set WEBKIT_DISABLE_COMPOSITING_MODE=1 while building the package, and that's what they're doing now.
Comment 3 Michael Catanzaro 2016-10-16 10:35:07 PDT
That's nuts though.

So g-ir-scanner actually dlopens WebKit and calls functions, that's why this crash is happening?
Comment 4 Alberto Garcia 2016-10-16 10:48:55 PDT
(In reply to comment #3)
> That's nuts though.
> 
> So g-ir-scanner actually dlopens WebKit and calls functions, that's why this
> crash is happening?

IIRC g-ir-scanner calls liferea (I don't remember the command-line options), which is already linked against WebKit, and it's the webkit_settings_new() call in Liferea that calls XCompositeQueryExtension(), which crashes the process.
Comment 5 Alberto Garcia 2016-10-16 11:13:37 PDT
This is the actual command called by g-ir-scanner:

./liferea --introspect-dump=/tmp/tmp-introspectw0lgbi6d/functions.txt,/tmp/tmp-introspectw0lgbi6d/dump.xml

And this is the backtrace:

Thread 1 "liferea" received signal SIGSEGV, Segmentation fault.
0xf0deceee in XQueryExtension () from /usr/lib/i386-linux-gnu/libX11.so.6
(gdb) bt
#0  0xf0deceee in XQueryExtension () from /usr/lib/i386-linux-gnu/libX11.so.6
#1  0xf0de0c6c in XInitExtension () from /usr/lib/i386-linux-gnu/libX11.so.6
#2  0xf0db9cc8 in XCompositeFindDisplay () from /usr/lib/i386-linux-gnu/libXcomposite.so.1
#3  0xf0db9e3b in XCompositeQueryExtension () from /usr/lib/i386-linux-gnu/libXcomposite.so.1
#4  0xf678ed15 in WebCore::PlatformDisplayX11::supportsXComposite () at ./Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp:80
#5  0xf58518f5 in WebKit::WebPreferences::platformInitializeStore () at ./Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp:63
#6  0xf56198ff in WebKit::WebPreferences::WebPreferences () at ./Source/WebKit2/UIProcess/WebPreferences.cpp:63
#7  0xf5619940 in WebKit::WebPreferences::create () at ./Source/WebKit2/UIProcess/WebPreferences.cpp:43
#8  0xf5807493 in _WebKitSettingsPrivate::_WebKitSettingsPrivate () at ./Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp:51
#9  webkit_settings_init () at ./Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp:94
#10 0xf46714b0 in g_type_create_instance () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#11 0xf4652bc7 in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#12 0xf465462c in g_object_newv () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#13 0xf4654cbd in g_object_new () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#14 0xf5807b9f in webkit_settings_new () at ./Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp:1294
#15 0x565a8d9e in liferea_webkit_impl_init (self=0x566115b0) at webkit.c:345
#16 0xf46714b0 in g_type_create_instance () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#17 0xf4652bc7 in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#18 0xf465462c in g_object_newv () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#19 0xf4654cbd in g_object_new () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#20 0x565a9890 in liferea_webkit_impl_new () at webkit.c:107
#21 liferea_webkit_init () at webkit.c:421
#22 0x56598e8e in liferea_htmlview_class_init (klass=0x56618000) at liferea_htmlview.c:203
#23 liferea_htmlview_class_intern_init (klass=0x56618000) at liferea_htmlview.c:144
#24 0xf466e337 in g_type_class_ref () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#25 0xf46a3da5 in dump_properties (type=type@entry=1449215696, out=out@entry=0x56614c38) at girepository/gdump.c:132
#26 0xf46a49ff in dump_object_type (out=0x56614c38, symbol=<optimized out>, type=<optimized out>) at girepository/gdump.c:255
#27 dump_type (out=0x56614c38, symbol=<optimized out>, type=<optimized out>) at girepository/gdump.c:397
#28 g_irepository_dump (arg=0x566183b8 "/tmp/tmp-introspectw0lgbi6d/functions.txt,/tmp/tmp-introspectw0lgbi6d/dump.xml", error=0xffffca38)
    at girepository/gdump.c:542
#29 0xf46aaef1 in g_irepository_introspect_cb (option_name=0x56610288 "--introspect-dump", 
    value=0x566183b8 "/tmp/tmp-introspectw0lgbi6d/functions.txt,/tmp/tmp-introspectw0lgbi6d/dump.xml", data=0x0, error=0xffffcbc0)
    at girepository/girepository.c:1593
#30 0xf4565c2d in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#31 0xf4566074 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#32 0xf4567973 in g_option_context_parse () from /lib/i386-linux-gnu/libglib-2.0.so.0
#33 0x5656991d in main (argc=<optimized out>, argv=<optimized out>) at main.c:209
Comment 6 Alberto Garcia 2016-10-17 01:23:15 PDT
Created attachment 291797 [details]
Patch

Ok, I actually think this is our bug. If we know that the display is not set we should simply return false instead of calling a function that we know is going to crash.
Comment 7 Carlos Garcia Campos 2016-10-17 01:35:38 PDT
Comment on attachment 291797 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=291797&action=review

> Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp:78
> -    if (!m_supportsXComposite) {
> +    if (!m_supportsXComposite && m_display) {

I agree but this will crash in debug builds. m_supportsXComposite is Optional<bool>, if we don't initialize it the .value() below will assert in debug because the value is not engaged. So, simply add an early return before this if so that when m_display is nullptr, the optional value is not even used.

> Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp:87
> -    if (!m_supportsXDamage) {
> +    if (!m_supportsXDamage && m_display) {

And same here
Comment 8 Alberto Garcia 2016-10-17 01:43:06 PDT
Created attachment 291800 [details]
Patch #2

How about this one?

This also removes the need to have the #else (GTK) in supportsXDamage()
Comment 9 Carlos Garcia Campos 2016-10-17 02:05:12 PDT
Comment on attachment 291800 [details]
Patch #2

Ok.
Comment 10 Alberto Garcia 2016-10-17 02:09:09 PDT
Committed r207403: <http://trac.webkit.org/changeset/207403>