LadybirdBrowser / ladybird

Truly independent web browser
https://ladybird.org
BSD 2-Clause "Simplified" License
21.73k stars 965 forks source link

Wasm + JS crash on uiua.org #907

Open mnlrsn opened 3 months ago

mnlrsn commented 3 months ago

To reproduce (verified on Apple M1):

  1. Launch Ladybird ./Meta/ladybird.sh run
  2. Go to https://www.uiua.org
  3. Wait for the page to load and the editor pane to appear
  4. Click in the editor pane and/or move the mouse over the editor

Result: Crash, error message in terminal:

libc++abi: Pure virtual function called!
3764525.950 Ladybird(91108): IPC::ConnectionBase (0x0000000129fddd00) had an error (IPC::transfer_message: Disconnected from peer), disconnecting.
3764525.951 Ladybird(91108): WebContent process crashed!
doctortheemh commented 3 months ago

Looks like a assertion failed in WASM, perhaps coming from LibWasm/AbstractMachine/Configuration.cpp:64

VERIFICATION FAILED: has<T>() at /home/doc/programming/ladybird/AK/Variant.h:382  
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-ak.so.0(ak_verification_failed+0xef) [0x7f9492ab516f]                                                                                                                                             /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0(+0x10f8319) [0x7f94980b5319]                                                                                                                                                             /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::Configuration::call(Wasm::Interpreter&, AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>, AK::Vector<Wasm::Value, 0ul>) 0x36e) [0x7f9491b2c0de]                                                                                                                                                                           /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::BytecodeInterpreter::call_address(Wasm::Configuration&, AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>) 0x807) [0x7f9491add777]                                                                                                                                                                                         /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::BytecodeInterpreter::interpret(Wasm::Configuration&) 0x14f) [0x7f9491adc46f]                                                                                                      /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::Configuration::execute(Wasm::Interpreter&) 0x34) [0x7f9491b2c1e4]                                                                                                                 /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::Configuration::call(Wasm::Interpreter&, AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>, AK::Vector<Wasm::Value, 0ul>) 0x325) [0x7f9491b2c095]                                                                                                                                                                           /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::BytecodeInterpreter::call_address(Wasm::Configuration&, AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>) 0x807) [0x7f9491add777]                                                                                                                                                                                         /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::BytecodeInterpreter::interpret(Wasm::Configuration&) 0x14f) [0x7f9491adc46f]                                                                                                      /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::Configuration::execute(Wasm::Interpreter&) 0x34) [0x7f9491b2c1e4]                                                                                                                 /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::Configuration::call(Wasm::Interpreter&, AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>, AK::Vector<Wasm::Value, 0ul>) 0x325) [0x7f9491b2c095]                                                                                                                                                                           /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::BytecodeInterpreter::call_address(Wasm::Configuration&, AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>) 0x807) [0x7f9491add777]                                                                                                                                                                                         /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::BytecodeInterpreter::interpret(Wasm::Configuration&, AK::DistinctNumeric<unsigned long, Wasm::__InstructionPointer_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Flags, AK::DistinctNumericFeature::Increment>&, Wasm::Instruction const&) 0xb6f5) [0x7f9491ae9d55]                                                                                                                          /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::BytecodeInterpreter::interpret(Wasm::Configuration&) 0x14f) [0x7f9491adc46f]                                                                                                      /home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::Configuration::execute(Wasm::Interpreter&) 0x34) [0x7f9491b2c1e4]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::Configuration::call(Wasm::Interpreter&, AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>, AK::Vector<Wasm::Value, 0ul>) 0x325) [0x7f9491b2c095]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::AbstractMachine::invoke(Wasm::Interpreter&, AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>, AK::Vector<Wasm::Value, 0ul>) 0x90) [0x7f9491ad4470]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-wasm.so.0 Wasm::AbstractMachine::invoke(AK::DistinctNumeric<unsigned long, Wasm::__FunctionAddress_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment>, AK::Vector<Wasm::Value, 0ul>) 0x78) [0x7f9491ad4348]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0(+0x10f893f) [0x7f94980b593f]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::NativeFunction::call() 0x4c) [0x7f9496d28a3c]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::NativeFunction::internal_call(JS::Value, AK::Span<JS::Value const>) 0x1c2) [0x7f9496d28602]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0(+0x24c057) [0x7f9496b94057]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::Bytecode::Interpreter::run_bytecode(unsigned long) 0x62f1) [0x7f9496b74531]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::Bytecode::Interpreter::run_executable(JS::Bytecode::Executable&, AK::Optional<unsigned long>, JS::Value) 0x222) [0x7f9496b6deb2]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::ECMAScriptFunctionObject::ordinary_call_evaluate_body() 0x19f) [0x7f9496c9b82f]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::ECMAScriptFunctionObject::internal_call(JS::Value, AK::Span<JS::Value const>) 0x25e) [0x7f9496c9b0be]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0(+0x24c057) [0x7f9496b94057]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::Bytecode::Interpreter::run_bytecode(unsigned long) 0xf3a) [0x7f9496b6f17a]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::Bytecode::Interpreter::run_executable(JS::Bytecode::Executable&, AK::Optional<unsigned long>, JS::Value) 0x222) [0x7f9496b6deb2]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::ECMAScriptFunctionObject::ordinary_call_evaluate_body() 0x19f) [0x7f9496c9b82f]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-js.so.0 JS::ECMAScriptFunctionObject::internal_call(JS::Value, AK::Span<JS::Value const>) 0x25e) [0x7f9496c9b0be]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0 Web::WebIDL::call_user_object_operation(Web::WebIDL::CallbackType&, AK::String const&, AK::Optional<JS::Value>, JS::MarkedVector<JS::Value, 0ul>) 0x129) [0x7f94980d7a89]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0 JS::Completion Web::WebIDL::call_user_object_operation<Web::DOM::Event*&>(Web::WebIDL::CallbackType&, AK::String const&, AK::Optional<JS::Value>, Web::DOM::Event*&) 0x135) [0x7f9497d3c7b5]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0 Web::DOM::EventDispatcher::inner_invoke(Web::DOM::Event&, AK::Vector<JS::Handle<Web::DOM::DOMEventListener>, 0ul>&, Web::DOM::Event::Phase, bool) 0x24c) [0x7f9497d3b9bc]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0 Web::DOM::EventDispatcher::invoke(Web::DOM::Event::PathEntry&, Web::DOM::Event&, Web::DOM::Event::Phase) 0xce) [0x7f9497d3bb6e]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0 Web::DOM::EventDispatcher::dispatch(JS::NonnullGCPtr<Web::DOM::EventTarget>, Web::DOM::Event&, bool) 0x7b6) [0x7f9497d3c4a6]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0 Web::DOM::Document::set_hovered_node(Web::DOM::Node*) 0x3a4) [0x7f9497cf1434]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0 Web::EventHandler::handle_mousemove(Gfx::Point<Web::CSSPixels>, Gfx::Point<Web::CSSPixels>, unsigned int, unsigned int) 0x36d) [0x7f9497ff5a6d]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/WebContent(+0x952db) [0x5588de4462db]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-web.so.0(+0x108c691) [0x7f9498049691]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-core.so.0 Core::Timer::timer_event(Core::TimerEvent&) 0xae) [0x7f9495201f0e]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-core.so.0 Core::EventReceiver::dispatch_event(Core::Event&, Core::EventReceiver*) 0xc6) [0x7f94951e7726]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/WebContent(+0x82063) [0x5588de433063]
/lib/x86_64-linux-gnu/libQt6Core.so.6(+0x16cb36) [0x7f94999b9b36]
/lib/x86_64-linux-gnu/libQt6Core.so.6 QTimer::timeout(QTimer::QPrivateSignal) 0x3a) [0x7f94999bdd7a]
/lib/x86_64-linux-gnu/libQt6Core.so.6 QObject::event(QEvent*) 0x1ce) [0x7f94999ac8de]
/lib/x86_64-linux-gnu/libQt6Core.so.6 QCoreApplication::notifyInternal2(QObject*, QEvent*) 0xed) [0x7f949997088d]
/lib/x86_64-linux-gnu/libQt6Core.so.6 QTimerInfoList::activateTimers() 0x309) [0x7f9499aa5689]
/lib/x86_64-linux-gnu/libQt6Core.so.6(+0x30a32c) [0x7f9499b5732c]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x299) [0x7f9491df57a9]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x54a38) [0x7f9491df5a38]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7f9491df5acc]
/lib/x86_64-linux-gnu/libQt6Core.so.6 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 0x6c) [0x7f9499b54f7c]
/lib/x86_64-linux-gnu/libQt6Core.so.6 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) 0x2aa) [0x7f949997a57a]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/../lib/liblagom-core.so.0 Core::EventLoop::exec() 0x37) [0x7f94951e0187]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/WebContent(+0x8fbc0) [0x5588de440bc0]
/home/doc/programming/ladybird/Build/ladybird-debug/libexec/WebContent(+0x15fd23) [0x5588de510d23]
alimpfard commented 3 months ago

While that PR fixes the crash described, I'd like to keep this issue open to track the error instead - which may not even be wasm-related:

1291835.137 WebContent(2338): (js error) ""
1291835.137 WebContent(2338): Unhandled JavaScript exception: [TypeError] Wasm execution trapped (WIP): Unreachable
1291835.137 WebContent(2338):     at _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h250e0a4489d3ed59
    at __wbg_adapter_44 (site-6deec7d2c0ea5726.js:232:132)
    at real (site-6deec7d2c0ea5726.js:209:21)

We've so far tracked it down to a call to getElementById(""), which yields some unexpected value, and throws from inside wasm.

Calling host fn func72___wbindgen_object_clone_ref
Calling host fn func35___wbg_getElementById_c369ff43f0db99cf
DocumentPrototype::get_element_by_id("")
Calling host fn func147___wbindgen_object_drop_ref
Calling host fn func142___wbg_new_abda76e883ba8a5f
Calling host fn func63___wbg_stack_658279fe44541cf6
Calling host fn func5___wbg_error_f851667af71bcfc6
(js error) ""