<?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>281226</bug_id>
          
          <creation_ts>2024-10-10 08:11:30 -0700</creation_ts>
          <short_desc>REGRESSION(186594@main) Web Inspector: Crash SIGSEGV in g_type_check_instance_is_fundamentally_a</short_desc>
          <delta_ts>2024-10-14 01:53:49 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=281298</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>DoNotImportToRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Pablo Saavedra">psaavedra</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>inspector-bugzilla-changes</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2066904</commentid>
    <comment_count>0</comment_count>
    <who name="Pablo Saavedra">psaavedra</who>
    <bug_when>2024-10-10 08:11:30 -0700</bug_when>
    <thetext>While using the Web Remote Inspector in WPEWebKit enabled via `WEBKIT_INSPECTOR_SERVER=0.0.0.0:11311`, the program terminates with a segmentation fault. Below are the details of the issue and backtrace.


#### **Steps to Reproduce:**
1. Set the environment variable to enable the Web Inspector:
   ```bash
   export WEBKIT_INSPECTOR_SERVER=0.0.0.0:11311
   ```
2. Launch WPEWebKit:
   ```bash
   wpe-launcher https://wpewebkit.org
   ```

#### **Observed Behavior:**
The program crashes with the following error:

```
Core was generated by `wpe-launcher https://wpewebkit.org&apos;.                                                                                                                                      
Program terminated with signal SIGSEGV, Segmentation fault.                                                                                                                                                                                   
#0  g_type_check_instance_is_fundamentally_a (type_instance=type_instance@entry=0xaaab0115c1c0, fundamental_type=fundamental_type@entry=80) at /usr/src/debug/glib-2.0/1_2.78.1-r0/gobject/gtype.c:4184                                       
4184      node = lookup_type_node_I (type_instance-&gt;g_class-&gt;g_type);                                                                                                                                                                         
[Current thread is 1 (LWP 1480)]                                                        
```

```
#0  g_type_check_instance_is_fundamentally_a (type_instance=type_instance@entry=0xaaab0115c1c0, fundamental_type=fundamental_type@entry=80) at /usr/src/debug/glib-2.0/1_2.78.1-r0/gobject/gtype.c:4184
#1  0x0000ffffaa25db7c in g_object_unref (_object=0xaaab0115c1c0) at /usr/src/debug/glib-2.0/1_2.78.1-r0/gobject/gobject.c:3810
#2  0x0000ffffabf6af28 in std::once_flag::_Prepare_execution::_Prepare_execution&lt;std::call_once&lt;Inspector::backendCommands()::{lambda()#1}&gt;(std::once_flag&amp;, Inspector::backendCommands()::{lambda()#1}&amp;&amp;)::{lambda()#1}&gt;(Inspector::backendCommands()::{lambda()#1}&amp;)::{lambda()#1}::_FUN() () from /devel1/rootfs/usr/lib/libWPEWebKit-2.0.so.2.4.0
#3  0x0000ffffaa113c30 in __pthread_once_slow (once_control=0xffffb0a42dd0 &lt;Inspector::backendCommands()::flag&gt;, init_routine=0xffffa80b61b0 &lt;std::__once_proxy()&gt;) at pthread_once.c:116
#4  0x0000ffffabf6b02c in Inspector::backendCommands() () from /devel1/rootfs/usr/lib/libWPEWebKit-2.0.so.2.4.0
#5  0x0000ffffabf6b154 in Inspector::backendCommandsHash() () from /devel1/rootfs/usr/lib/libWPEWebKit-2.0.so.2.4.0
#6  0x0000ffffabf6452c in Inspector::RemoteInspectorServer::setupInspectorClient(WTF::SocketConnection&amp;, char const*) () from /devel1/rootfs/usr/lib/libWPEWebKit-2.0.so.2.4.0
#7  0x0000ffffabf64718 in Inspector::RemoteInspectorServer::messageHandlers()::{lambda(WTF::SocketConnection&amp;, _GVariant*, void*)#3}::_FUN(WTF::SocketConnection&amp;, _GVariant*, void*) () from /devel1/rootfs/usr/lib/libWPEWebKit-2.0.so.2.4.0
#8  0x0000ffffac9cf938 in WTF::SocketConnection::readMessage() () from /devel1/rootfs/usr/lib/libWPEWebKit-2.0.so.2.4.0
#9  0x0000ffffac9cfb18 in WTF::SocketConnection::read() () from /devel1/rootfs/usr/lib/libWPEWebKit-2.0.so.2.4.0
#10 0x0000ffffac9cfc58 in WTF::Detail::CallableWrapper&lt;WTF::SocketConnection::SocketConnection(WTF::GRefPtr&lt;_GSocketConnection&gt;&amp;&amp;, WTF::HashMap&lt;WTF::CString, std::pair&lt;WTF::CString, void (*)(WTF::SocketConnection&amp;, _GVariant*, void*)&gt;, WTF::DefaultHash&lt;WTF::CString&gt;, WTF::HashTraits&lt;WTF::CString&gt;, WTF::HashTraits&lt;std::pair&lt;WTF::CString, void (*)(WTF::SocketConnection&amp;, _GVariant*, void*)&gt; &gt;, WTF::HashTableTraits&gt; const&amp;, void*)::{lambda(GIOCondition)#1}, int, GIOCondition&gt;::call(GIOCondition) () from /devel1/rootfs/usr/lib/libWPEWebKit-2.0.so.2.4.0
#11 0x0000ffffa9a170c0 in socket_source_dispatch (source=0xaaab01161b50, callback=0xffffac9cccf0 &lt;WTF::GSocketMonitor::socketSourceCallback(_GSocket*, GIOCondition, WTF::GSocketMonitor*)&gt;, user_data=0xffff9b02c5b0) at /usr/src/debug/glib-2.0/1_2.78.1-r0/gio/gsocket.c:4072
#12 0x0000ffffb0b5a138 in g_main_dispatch (context=context@entry=0xaaab0106a6c0) at /usr/src/debug/glib-2.0/1_2.78.1-r0/glib/gmain.c:3476
#13 0x0000ffffb0b5dc44 in g_main_context_dispatch_unlocked (context=0xaaab0106a6c0) at /usr/src/debug/glib-2.0/1_2.78.1-r0/glib/gmain.c:4284
#14 g_main_context_iterate_unlocked (context=0xaaab0106a6c0, block=block@entry=1, dispatch=dispatch@entry=1, self=&lt;optimized out&gt;) at /usr/src/debug/glib-2.0/1_2.78.1-r0/glib/gmain.c:4349
#15 0x0000ffffb0b5e740 in g_main_loop_run (loop=loop@entry=0xaaab01078d00) at /usr/src/debug/glib-2.0/1_2.78.1-r0/glib/gmain.c:4551
#16 0x0000aaaad8ce2250 in main (argc=&lt;optimized out&gt;, argv=&lt;optimized out&gt;) at /usr/src/debug/wpe-bare-app/git-r0/wpe-bare-app.c:123
```


The crash appears to occur after trying to interact with the Web Inspector resources:

```
recvfrom(30, &quot;\0\0\0&gt;\1SetupInspectorClient\00047ABA4&quot;..., 4096, 0, NULL, NULL) = 67
openat(AT_FDCWD, &quot;/usr/share/wpe-webkit-2.0/inspector.gresource&quot;, O_RDONLY|O_CLOEXEC) = 31
newfstatat(31, &quot;&quot;, {st_mode=S_IFREG|0644, st_size=1367398, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 1367398, PROT_READ, MAP_PRIVATE, 31, 0) = 0xffff60682000
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xaaa000000002} ---
Segmentation fault (core dumped)
```

The `/usr/share/wpe-webkit-2.0/inspector.gresource` file exists and appears to be loaded correctly:
```
# ls -l /usr/share/wpe-webkit-2.0/inspector.gresource
-rw-r--r-- 1 root root 1367398 Oct 10 13:26 /usr/share/wpe-webkit-2.0/inspector.gresource
```

#### **Expected Behavior:**
Launch the Remote Web Inspector without crashing.

#### **Additional Notes:**
- WPEWebKit version: upstream
- GLib version: 2.78.1
- The crash seems to occur within the `g_type_check_instance_is_fundamentally_a` function in GLib, when handling a type instance.
- This is related to this change: 8ceb1da47e75 [WPE] Pack inspector resources in a .gresource file instead of a shared library https://bugs.webkit.org/show_bug.cgi?id=186594</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2067688</commentid>
    <comment_count>1</comment_count>
    <who name="Pablo Saavedra">psaavedra</who>
    <bug_when>2024-10-14 01:53:22 -0700</bug_when>
    <thetext>Fixed in https://bugs.webkit.org/show_bug.cgi?id=281298</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>