Bug 225189 - Stopping LayoutTest WebSocket Server turns it into a zombie
Summary: Stopping LayoutTest WebSocket Server turns it into a zombie
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Sneddon [:gsnedders]
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-29 06:11 PDT by Sam Sneddon [:gsnedders]
Modified: 2021-10-30 10:10 PDT (History)
5 users (show)

See Also:


Attachments
Patch (5.54 KB, patch)
2021-10-29 09:43 PDT, Sam Sneddon [:gsnedders]
no flags Details | Formatted Diff | Diff
Patch (6.61 KB, patch)
2021-10-29 10:34 PDT, Sam Sneddon [:gsnedders]
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Sneddon [:gsnedders] 2021-04-29 06:11:30 PDT
Stopping the WebSocket server on Linux always hits the timeout:

> __GI___select (/usr/lib/libc-2.33.so:0)
> _wait_for_action (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/http_server_base.py:203)
> _stop_running_server (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py:213)
> _stop_running_server (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/websocket_server.py:174)
> stop (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/http_server_base.py:140)
> stop_websocket_server (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/port/base.py:978)
> stop_servers (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:229)
> run (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py:442)
> run (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py:488)
> main (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py:93)
> <module> (/mnt/home-extra/gsnedders/Documents/other-projects/WebKit/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py:495)

_wait_for_action sleep-loops until its action returns True; it is called with Lighttpd._check_and_kill as the action from its caller. This action essentially checks Executive.check_running_pid (which calls kill(pid, 0)) and then calls Executive.kill_process if that's True.

However, despite the long delay, it appears that the first Executive.kill_process is killing it, turning it into a zombie. It appears that on Darwin, kill(pid, 0) returns non-zero when pid is a zombie, but on GNU/Linux the same returns 0 when pid is a zombie.

We should really be calling os.wait (or, better, keeping the subprocess.Popen object around to call Popen.wait) while waiting for it to stop. This is somewhat painful on Py<3.3, given os.wait itself just busyloops until it succeeds, whereas we really want to have some timeout there.
Comment 1 Radar WebKit Bug Importer 2021-05-06 06:12:16 PDT
<rdar://problem/77604119>
Comment 2 Sam Sneddon [:gsnedders] 2021-10-29 09:43:19 PDT
Created attachment 442825 [details]
Patch
Comment 3 Sam Sneddon [:gsnedders] 2021-10-29 10:00:21 PDT
EWS failures (both Py2 and Py3) for webkitpy are:

[660/2054] webkitpy.layout_tests.servers.http_server_unittest.TestHttpServer.test_win32_start_and_stop erred:
  Traceback (most recent call last):
    File "/Volumes/Data/worker/WebKitPy-Tests-EWS/build/Tools/Scripts/webkitpy/layout_tests/servers/http_server_unittest.py", line 107, in test_win32_start_and_stop
      self.assertEqual(['taskkill.exe', '/f', '/t', '/pid', 42], host.executive.calls[1])
  IndexError: list index out of range
Comment 4 Sam Sneddon [:gsnedders] 2021-10-29 10:34:34 PDT
Created attachment 442842 [details]
Patch
Comment 5 EWS 2021-10-30 10:09:59 PDT
Committed r285081 (243723@main): <https://commits.webkit.org/243723@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 442842 [details].