<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>193826</bug_id>
          
          <creation_ts>2019-01-25 08:47:00 -0800</creation_ts>
          <short_desc>[WPE] Inspector server crashes because libWPEWebInspectorResources.so is looked up in an installed location</short_desc>
          <delta_ts>2019-01-25 08:56:23 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WPE WebKit</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=186594</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Charlie Turner">cturner</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aperez</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1498255</commentid>
    <comment_count>0</comment_count>
    <who name="Charlie Turner">cturner</who>
    <bug_when>2019-01-25 08:47:00 -0800</bug_when>
    <thetext>Using trunk WPE, I run a WPE minibrowser like so,

% WEBKIT_INSPECTOR_SERVER=&apos;localhost:9998&apos; run-minibrowser --wpe --debug

And then connect to it from Epiphany 3.30.2 I see a crash, the backtrace is attached for completeness,

#0  WTFCrash () at ../../Source/WTF/wtf/Assertions.cpp:255
#1  0x00007f3a3ab2e5ec in _ZN9Inspector15backendCommandsEv () at ../../Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorUtils.cpp:54
#2  0x00007f3a3ab2e678 in _ZN9Inspector19backendCommandsHashEv () at ../../Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorUtils.cpp:62
#3  0x00007f3a3ab1bb0d in _ZN9Inspector21RemoteInspectorServer20setupInspectorClientEP16_GDBusConnectionPKc (
    this=0x7f3a406025c0 &lt;_ZZN9Inspector21RemoteInspectorServer9singletonEvE6server&gt;, clientConnection=0x243c790, 
    clientBackendCommandsHash=0x7f39b400a2f0 &quot;01F73C9BE6930FD0F80D63D575FA3C703BA803AC&quot;)
    at ../../Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorServer.cpp:277
#4  0x00007f3a3ab1ac6b in Inspector::RemoteInspectorServer::&lt;lambda(GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, GDBusMethodInvocation*, gpointer)&gt;::operator()(GDBusConnection *, const gchar *, const gchar *, const gchar *, const gchar *, GVariant *, GDBusMethodInvocation *, gpointer) const (__closure=0x0, connection=0x243c790, methodName=0x7f39b4009190 &quot;SetupInspectorClient&quot;, parameters=0x7f39b0003d80, 
    invocation=0x243f1c0, userData=0x7f3a406025c0 &lt;_ZZN9Inspector21RemoteInspectorServer9singletonEvE6server&gt;)
    at ../../Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorServer.cpp:120
#5  0x00007f3a3ab1b0f2 in Inspector::RemoteInspectorServer::&lt;lambda(GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, GDBusMethodInvocation*, gpointer)&gt;::_FUN(GDBusConnection *, const gchar *, const gchar *, const gchar *, const gchar *, GVariant *, GDBusMethodInvocation *, gpointer) () at ../../Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorServer.cpp:156
#6  0x00007f3a2b279bf9 in call_in_idle_cb (user_data=&lt;optimized out&gt;) at ../../Source/glib-2.58.1/gio/gdbusconnection.c:4842
#7  0x00007f3a2b05c998 in g_main_dispatch (context=0x204c190) at ../../Source/glib-2.58.1/glib/gmain.c:3182
#8  g_main_context_dispatch (context=context@entry=0x204c190) at ../../Source/glib-2.58.1/glib/gmain.c:3847
#9  0x00007f3a2b05cd58 in g_main_context_iterate (context=0x204c190, block=block@entry=1, dispatch=dispatch@entry=1, self=&lt;optimized out&gt;)
    at ../../Source/glib-2.58.1/glib/gmain.c:3920
#10 0x00007f3a2b05d042 in g_main_loop_run (loop=0x204c6e0) at ../../Source/glib-2.58.1/glib/gmain.c:4116
#11 0x000000000040dcca in main (argc=1, argv=0x7ffee2141348) at ../../Tools/MiniBrowser/wpe/main.cpp:203


The problematic function in RemoteInspectorUtils.cpp:54 is like this,

GRefPtr&lt;GBytes&gt; backendCommands()
{
#if PLATFORM(WPE)
    static std::once_flag flag;
    std::call_once(flag, [] {
        GModule* resourcesModule = g_module_open(PKGLIBDIR G_DIR_SEPARATOR_S &quot;libWPEWebInspectorResources.so&quot;, G_MODULE_BIND_LAZY);
        if (!resourcesModule) {
            WTFLogAlways(&quot;Error loading libWPEWebInspectorResources.so: %s&quot;, g_module_error());
            return;
        }

        g_module_make_resident(resourcesModule);
    });
#endif
    GRefPtr&lt;GBytes&gt; bytes = adoptGRef(g_resources_lookup_data(INSPECTOR_BACKEND_COMMANDS_PATH, G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr));
    ASSERT(bytes);
    return bytes;
}

Here, g_resources_lookup_data returns a nullptr, which causes the crash.

After discussing with Adrian offline about this, some options are,

 1) Provide an env var with a location to the libWPEWebInspectorResources.so file in the WebKitBuild dir
 2) Move the path information into a gresources file

As a workaround, I tried creating a symlink to the WebKitBuild directory from the assumed system-wide install dir like so,

&apos;/usr/local/lib64/wpe-webkit-0.1/libWPEWebInspectorResources.so&apos; -&gt; &apos;/home/cturner/webkit/webkit-wpe/WebKitBuild/Debug/lib/libWPEWebInspectorResources.so&apos;

Then a crash is not observed, but I get instead a Connection reset by peer,

RemoteInspector failed to connect to inspector server at: localhost:9998: Error receiving data: Connection reset by peer</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1498257</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-01-25 08:49:07 -0800</bug_when>
    <thetext>(In reply to Charlie Turner from comment #0)
&gt;  2) Move the path information into a gresources file

This seems like the better solution....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1498261</commentid>
    <comment_count>2</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2019-01-25 08:52:32 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #1)
&gt; (In reply to Charlie Turner from comment #0)
&gt; &gt;  2) Move the path information into a gresources file
&gt; 
&gt; This seems like the better solution....

I would go with this option as well. It would allow to use the resource
relocation support in GLib (using G_RESOURCE_OVERLAYS) as well, which
may come in handy in some situations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1498262</commentid>
    <comment_count>3</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2019-01-25 08:53:59 -0800</bug_when>
    <thetext>(In reply to Adrian Perez from comment #2)
&gt; (In reply to Michael Catanzaro from comment #1)
&gt; &gt; (In reply to Charlie Turner from comment #0)
&gt; &gt; &gt;  2) Move the path information into a gresources file
&gt; &gt; 
&gt; &gt; This seems like the better solution....
&gt; 
&gt; I would go with this option as well. It would allow to use the resource
&gt; relocation support in GLib (using G_RESOURCE_OVERLAYS) as well, which
&gt; may come in handy in some situations.

Also, I was having a déja-vù when going over the idea of using
GResource... and yes, it was me who filed bug #186594 a while ago
precisely for this :D</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>