LibWeb: Clean up main thread promise when exiting RenderingThreads
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macOS, macos-15, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macOS, macOS-universal2, macos-15) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, Linux, Linux-x86_64, blacksmith-8vcpu-ubuntu-2404) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

Not cleaning these up by rejecting or resolving the promise causes
the main thread to try to reject them at EventLoop::exit() time.

If the RenderThread has already been destroyed by then, we get into
use-after-free territory and segfault.
This commit is contained in:
Andrew Kaster 2025-05-29 16:39:43 -06:00 committed by Alexander Kalenik
parent 3178679f0b
commit 0f81f021ce
Notes: github-actions[bot] 2025-05-30 14:19:24 +00:00

View file

@ -26,8 +26,8 @@ RenderingThread::RenderingThread()
RenderingThread::~RenderingThread()
{
m_exit = true;
m_rendering_task_ready_wake_condition.signal();
// Note: Promise rejection is expected to signal the thread to exit.
m_main_thread_exit_promise->reject(Error::from_errno(ECANCELED));
(void)m_thread->join();
}