mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 07:22:21 +00:00
LibWasm+LibWeb: Throw a js stack-overflow error if wasm stack overflows
Follows the spec.
This commit is contained in:
parent
9ae85e5c68
commit
39b637a446
Notes:
github-actions[bot]
2025-05-22 06:37:26 +00:00
Author: https://github.com/alimpfard
Commit: 39b637a446
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4833
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 20 additions and 4 deletions
|
@ -474,7 +474,12 @@ JS::NativeFunction* create_native_function(JS::VM& vm, Wasm::FunctionAddress add
|
|||
if (result.is_trap()) {
|
||||
if (auto ptr = result.trap().data.get_pointer<Wasm::ExternallyManagedTrap>())
|
||||
return ptr->unsafe_external_object_as<JS::Completion>();
|
||||
return vm.throw_completion<RuntimeError>(TRY_OR_THROW_OOM(vm, String::formatted("Wasm execution trapped (WIP): {}", result.trap().format())));
|
||||
auto& trap = result.trap().data.get<ByteString>();
|
||||
// https://webassembly.github.io/spec/js-api/#stack-overflow
|
||||
// 6.1. Whenever a stack overflow occurs in WebAssembly code, the same class of exception is thrown as for a stack overflow in JavaScript.
|
||||
if (trap.ends_with(Wasm::Constants::stack_exhaustion_message))
|
||||
return vm.throw_completion<JS::InternalError>(JS::ErrorType::CallStackSizeExceeded);
|
||||
return vm.throw_completion<RuntimeError>(TRY_OR_THROW_OOM(vm, String::formatted("Wasm execution trapped (WIP): {}", trap)));
|
||||
}
|
||||
|
||||
if (result.values().is_empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue