<?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>240716</bug_id>
          
          <creation_ts>2022-05-20 07:44:02 -0700</creation_ts>
          <short_desc>REGRESSION(r290375) [GStreamer] Deadlock in WebProcess termination if AppendPipeline is started</short_desc>
          <delta_ts>2022-05-23 06:15:12 -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>WPE WebKit</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=191876</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=237084</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="Olivier Blin">olivier.blin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aboya</cc>
    
    <cc>aperez</cc>
    
    <cc>bandou.yacine</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>eocanha</cc>
    
    <cc>loic.yhuel</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>pnormand</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1870707</commentid>
    <comment_count>0</comment_count>
      <attachid>459617</attachid>
    <who name="Olivier Blin">olivier.blin</who>
    <bug_when>2022-05-20 07:44:02 -0700</bug_when>
    <thetext>Created attachment 459617
Test case

Since r290375, GStreamer ports are calling gst_deinit() at WebProcess termination.

This is causing a deadlock if a MSE SourceBuffer has been instantiated.
That is because the GstTask from the appsrc element in the AppendPipeline is still running.

The attached test page allows the reproduce the deadlock.
It has been adapted from Alicia&apos;s test case in bug 191876.

To reproduce:
./Tools/Scripts/run-minibrowser --wpe file:///path/to/deadlock-at-exit-if-appendpipeline-started.html &amp;
killall MiniBrowser
ps

You can see that WPEWebProcess is still runing.
It is blocked in the gst_deinit() call.

Relevant callstacks during the deadlock:

Thread 13 (Thread 0x7f99da401700 (LWP 758768)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f9b60f11623 in g_cond_wait () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f9b5e129517 in gst_app_src_create (bsrc=0xc6d850 [GstBaseSrc|appsrc0], offset=&lt;optimized out&gt;, size=4096, buf=0x7f99da400938) at gstappsrc.c:1279
#3  0x00007f9b5e0e34dd in gst_base_src_get_range (src=src@entry=0xc6d850 [GstBaseSrc|appsrc0], offset=offset@entry=0, length=&lt;optimized out&gt;, buf=buf@entry=0x7f99da400a18) at gstbasesrc.c:2527
#4  0x00007f9b5e0e65bc in gst_base_src_loop (pad=0xbc8080 [GstPad|src]) at gstbasesrc.c:2851
#5  0x00007f9b60d04107 in gst_task_func (task=0xbfa3b0 [GstTask|appsrc0:src]) at gsttask.c:328
#6  0x00007f9b60eee374 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#7  0x00007f9b60eedad1 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8  0x00007f9b5e608609 in start_thread (arg=&lt;optimized out&gt;) at pthread_create.c:477
#9  0x00007f9b60831133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f9b5cbbff80 (LWP 758735)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f9b60f11623 in g_cond_wait () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f9b60eeef4c in g_thread_pool_free () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f9b60d03eed in init_klass_pool (klass=&lt;optimized out&gt;) at gsttask.c:161
#4  0x00007f9b60d04446 in gst_task_cleanup_all () at gsttask.c:381
#5  0x00007f9b60c8487c in gst_deinit () at gst.c:1095
#6  0x00007f9b633f9ae1 in WebKit::WebProcessMainWPE::platformFinalize() (ocEE3endEv=&lt;error reading variable: Unhandled dwarf expression opcode 0x0&gt;) at ../../Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp:68
#7  0x00007f9b633f9991 in WebKit::AuxiliaryProcessMainBase&lt;WebKit::WebProcess, true&gt;::run(int, char**) (ocEE3endEv=Python Exception &lt;class &apos;gdb.MemoryError&apos;&gt; Cannot access memory at address 0xe5: 
#8  0x00007f9b633f8fa0 in WebKit::AuxiliaryProcessMain&lt;WebKit::WebProcessMainWPE&gt;(int, char**) (e *, std::unique_ptr&lt;IPC::MessageReceiveQueue, std::default_delete&lt;IPC::MessageReceiveQueue&gt; &gt; &gt; &gt;=Python Exception &lt;class &apos;gdb.MemoryError&apos;&gt; Cannot access memory at address 0xf: 
#9  0x00007f9b633f8dcb in WebKit::WebProcessMain(int, char**) (e *, std::unique_ptr&lt;IPC::MessageReceiveQueue, std::default_delete&lt;IPC::MessageReceiveQueue&gt; &gt; &gt; &gt;=Python Exception &lt;class &apos;gdb.MemoryError&apos;&gt; Cannot access memory at address 0x8c73: 
#10 0x0000000000401152 in main(int, char**) (argc=3, argv=0x7fff43ca15a8) at ../../Source/WebKit/WebProcess/EntryPoint/unix/WebProcessMain.cpp:31</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1870709</commentid>
    <comment_count>1</comment_count>
    <who name="Olivier Blin">olivier.blin</who>
    <bug_when>2022-05-20 07:47:55 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/830</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871146</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-05-23 06:15:09 -0700</bug_when>
    <thetext>Committed r294634 (250860@main): &lt;https://commits.webkit.org/250860@main&gt;

Reviewed commits have been landed. Closing PR #830 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>459617</attachid>
            <date>2022-05-20 07:44:02 -0700</date>
            <delta_ts>2022-05-20 07:44:02 -0700</delta_ts>
            <desc>Test case</desc>
            <filename>deadlock-at-exit-if-appendpipeline-started.html</filename>
            <type>text/html</type>
            <size>1172</size>
            <attacher name="Olivier Blin">olivier.blin</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KPHNjcmlwdD4KICAgIGZ1bmN0
aW9uIHdhaXRFdmVudFByb21pc2Uob2JqZWN0LCBldmVudE5hbWUpIHsKICAgICAgICByZXR1cm4g
bmV3IFByb21pc2UocmVzb2x2ZSA9PiB7CiAgICAgICAgICAgIGZ1bmN0aW9uIGxpc3RlbmVyKCkg
ewogICAgICAgICAgICAgICAgcmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgb2JqZWN0LnJlbW92
ZUV2ZW50TGlzdGVuZXIoZXZlbnROYW1lLCBsaXN0ZW5lcik7CiAgICAgICAgICAgIH0KICAgICAg
ICAgICAgb2JqZWN0LmFkZEV2ZW50TGlzdGVuZXIoZXZlbnROYW1lLCBsaXN0ZW5lcik7CiAgICAg
ICAgfSk7CiAgICB9CgogICAgYXN5bmMgZnVuY3Rpb24gY3JlYXRlQW5kRGVzdHJveU1lZGlhU291
cmNlKCkKICAgIHsKICAgICAgICBjb25zdCBtaW1lVHlwZSA9ICJ2aWRlby9tcDQ7IGNvZGVjcz1c
Im1wNGEuNDAuMixhdmMxLjRkNDAwZFwiIjsKCiAgICAgICAgY29uc3QgbWVkaWFFbGVtZW50ID0g
ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgidmlkZW8iKTsKICAgICAgICBkb2N1bWVudC5ib2R5LmFw
cGVuZENoaWxkKG1lZGlhRWxlbWVudCk7CgogICAgICAgIGNvbnN0IG1lZGlhU291cmNlID0gbmV3
IE1lZGlhU291cmNlKCk7CiAgICAgICAgY29uc3QgbWVkaWFTb3VyY2VVUkwgPSBVUkwuY3JlYXRl
T2JqZWN0VVJMKG1lZGlhU291cmNlKTsKICAgICAgICBtZWRpYUVsZW1lbnQuc3JjID0gbWVkaWFT
b3VyY2VVUkw7CiAgICAgICAgYXdhaXQgd2FpdEV2ZW50UHJvbWlzZShtZWRpYVNvdXJjZSwgInNv
dXJjZW9wZW4iKTsKICAgICAgICBVUkwucmV2b2tlT2JqZWN0VVJMKG1lZGlhU291cmNlVVJMKTsK
CiAgICAgICAgY29uc3Qgc291cmNlQnVmZmVyID0gbWVkaWFTb3VyY2UuYWRkU291cmNlQnVmZmVy
KG1pbWVUeXBlKTsKICAgICAgICBtZWRpYVNvdXJjZS5yZW1vdmVTb3VyY2VCdWZmZXIoc291cmNl
QnVmZmVyKTsKICAgCiAgICAgICAgY29uc29sZS5sb2coIlRlYXJpbmcgZG93bi4uLiIpOwogICAg
ICAgIGRvY3VtZW50LmJvZHkucmVtb3ZlQ2hpbGQobWVkaWFFbGVtZW50KTsKICAgICAgICBjb25z
b2xlLmxvZygiVGVzdCBkb25lLiIpOwogICAgfQoKICAgIHdpbmRvdy5vbmxvYWQgPSBjcmVhdGVB
bmREZXN0cm95TWVkaWFTb3VyY2U7Cjwvc2NyaXB0Pgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>