<?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>280366</bug_id>
          
          <creation_ts>2024-09-25 16:37:42 -0700</creation_ts>
          <short_desc>Race condition leading to failure in readPIDFromPeer() due to interrupted system call and subsequent crash</short_desc>
          <delta_ts>2024-09-26 02:39:16 -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>Platform</component>
          <version>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Povilas Kanapickas">povilas</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2063186</commentid>
    <comment_count>0</comment_count>
    <who name="Povilas Kanapickas">povilas</who>
    <bug_when>2024-09-25 16:37:42 -0700</bug_when>
    <thetext>readPIDFromPeer() contains a recvmsg() call which does not protect against EINTR being returned.

This problem has been observed in a automated end-to-end test setup involving Playwright and WPE Webkit, so it will be hard to reproduce outside the environment where the errors occurred. However, the following has been observed in strace:

[pid 23174] 20:38:42.188600 execve(&quot;/root/.cache/ms-playwright/webkit-2070/minibrowser-wpe/bin/WPEWebProcess&quot;, [&quot;/root/.cache/ms-playwright/webki&quot;..., &quot;11&quot;, &quot;17&quot;, &quot;19&quot;], 0x55d8d855d420 /* 53 vars */ &lt;unfinished ...&gt;
&lt;...&gt;
[pid 23174] 20:39:09.918082 +++ exited with 0 +++
&lt;...&gt;
[pid 23157] 20:39:09.918396 &lt;... recvmsg resumed&gt;{msg_namelen=0}, 0) = -1 EINTR (Interrupted system call)
&lt;...&gt;
[pid 23157] 20:39:09.918776 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=23174, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
&lt;...&gt;
[pid 23157] 20:39:09.923932 write(2, &quot;\n** (MiniBrowser:23157): ERROR *&quot;..., 126 &lt;unfinished ...&gt;

Which later leads to the following error message:

(MiniBrowser:23842): ERROR **: 20:39:09.919: readPIDFromPeer: Failed to read pid from PID socket: Interrupted system call

The browser then crashes.

Given that the child process exited with non-erroneous exit code zero, it is reasonable to expect that readPIDFromPeer() should handle this order of events.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2063213</commentid>
    <comment_count>1</comment_count>
    <who name="Povilas Kanapickas">povilas</who>
    <bug_when>2024-09-25 17:20:55 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/34268</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2063330</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-09-26 02:38:13 -0700</bug_when>
    <thetext>Committed 284274@main (57a73ac7aa73): &lt;https://commits.webkit.org/284274@main&gt;

Reviewed commits have been landed. Closing PR #34268 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2063331</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-09-26 02:39:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/136741794&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>