Skip to content

Commit

Permalink
LibJS/Bytecode: Do a stack check when entering run_bytecode()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
awesomekling committed May 7, 2024
1 parent ebe6ec6 commit a020a07
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Userland/Libraries/LibJS/Bytecode/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<InternalError>(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();
Expand Down

0 comments on commit a020a07

Please sign in to comment.