ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

LibWeb: Don't try to wait for HTTP server to exit if kill call fails

Open tcl3 opened this issue 1 year ago • 2 comments

This change fixes a crash I saw locally where headless-browser would always crash with the following error just prior to exit:

VERIFICATION FAILED: !_temporary_result.is_error() at /home/tim/repos/ladybird/UI/Headless/Fixture.cpp:83
/home/tim/repos/ladybird/Build/release/lib/liblagom-ak.so.0(ak_verification_failed+0xef) [0x7032bd52790f]
/home/tim/repos/ladybird/Build/release/bin/headless-browser(+0x143e0) [0x56277a50a3e0]
/home/tim/repos/ladybird/Build/release/bin/headless-browser(+0x12658) [0x56277a508658]
/home/tim/repos/ladybird/Build/release/bin/headless-browser(+0x127f9) [0x56277a5087f9]
/home/tim/repos/ladybird/Build/release/bin/headless-browser(+0x268ee) [0x56277a51c8ee]
/home/tim/repos/ladybird/Build/release/bin/headless-browser(+0x27542) [0x56277a51d542]
/lib/x86_64-linux-gnu/libc.so.6(+0x2a1ca) [0x7032bce2a1ca]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b) [0x7032bce2a28b]

This happened because the call to waitpid failed for the HTTP server process. This was because the HTTP server failed to start on my local machine because the address it wanted to use was already in use.

We now don't call waitpid if the prior call to kill failed.

I've also included a small fix to LibCore to return the correct error code from Process::wait_for_termination() if waitpid fails.

tcl3 avatar Dec 01 '24 15:12 tcl3

Is there any reason we still MUST the wait_for_termination() call? My PR (#2553) partially addresses this by just warning when that fails instead of crashing.

rgret-dev avatar Dec 01 '24 15:12 rgret-dev

This PR doesn't really have a great impact now that #2553 has been merged, but I've updated the new code so that waitpid is not called if the call to kill fails.

tcl3 avatar Dec 06 '24 04:12 tcl3