From a020a0779da5eaee60ca05232f6f92b106b72a92 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 7 May 2024 07:50:19 +0200 Subject: [PATCH] LibJS/Bytecode: Do a stack check when entering run_bytecode() If we don't have enough stack space, throw an exception while we still can, and give the caller a chance to recover. This particular problem will go away once we make calls non-recursive. --- Userland/Libraries/LibJS/Bytecode/Interpreter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index cb47b2b2c72..396403da219 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -339,6 +339,11 @@ Interpreter::HandleExceptionResponse Interpreter::handle_exception(size_t& progr FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point) { + if (vm().did_reach_stack_space_limit()) { + reg(Register::exception()) = vm().throw_completion(ErrorType::CallStackSizeExceeded).release_value().value(); + return; + } + auto& running_execution_context = vm().running_execution_context(); auto* locals = running_execution_context.locals.data(); auto& accumulator = this->accumulator();