LadybirdBrowser / ladybird

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

Clearing input value on focus causes crash when typing #529

Open vpzomtrrfrt opened 1 month ago

vpzomtrrfrt commented 1 month ago
<!DOCTYPE html>
<html>
        <body>
                <input id="input" type="text" value="fake placeholder" />
                <script>
                        const input = document.getElementById("input");

                        input.addEventListener("focus", () => {
                                input.value = "";
                        });
                </script>
        </body>
</html>

Clicking the input field and attempting to type a new value usually crashes the WebContent process. Somewhat inconsistent, sometimes it just works and sometimes it does nothing

Backtrace:

VERIFICATION FAILED: start + length <= m_length at /home/colin/ladybird/AK/StringView.h:130
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-ak.so.0(ak_verification_failed+0x8a) [0x7f6f4099e8c3]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-web.so.0(+0x97183b) [0x7f6f41d7183b]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-web.so.0 Web::EditEventHandler::handle_insert(JS::NonnullGCPtr<Web::DOM::Position>, AK::String) 0x18d) [0x7f6f4210a913]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-web.so.0 Web::EditEventHandler::handle_insert(JS::NonnullGCPtr<Web::DOM::Position>, unsigned int) 0x8c) [0x7f6f4210a736]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-web.so.0 Web::EventHandler::handle_keydown(Web::UIEvents::KeyCode, unsigned int, unsigned int) 0x6d3) [0x7f6f4210c13d]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-web.so.0 Web::Page::handle_keydown(Web::UIEvents::KeyCode, unsigned int, unsigned int) 0x28) [0x7f6f421113ec]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xb990d) [0x5580c714e90d]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xbe670) [0x5580c7153670]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xbe72b) [0x5580c715372b]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-web.so.0(+0xb817cf) [0x7f6f41f817cf]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-web.so.0(+0xd61f01) [0x7f6f42161f01]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-web.so.0(+0xd61f15) [0x7f6f42161f15]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-core.so.0(+0x4309b) [0x7f6f412dc09b]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-core.so.0 Core::Timer::timer_event(Core::TimerEvent&) 0x33) [0x7f6f412f8141]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-core.so.0 Core::EventReceiver::event(Core::Event&) 0x2b) [0x7f6f412db311]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-core.so.0 Core::EventReceiver::dispatch_event(Core::Event&, Core::EventReceiver*) 0x7e) [0x7f6f412db5d2]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xa52df) [0x5580c713a2df]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xa57f4) [0x5580c713a7f4]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xa5859) [0x5580c713a859]
/usr/lib64/libQt6Core.so.6(+0x2c8e76) [0x7f6f42cc8e76]
/usr/lib64/libQt6Core.so.6 QTimer::timeout(QTimer::QPrivateSignal) 0x3e) [0x7f6f42c88c9e]
/usr/lib64/libQt6Core.so.6 QObject::event(QEvent*) 0x1c6) [0x7f6f42c6bf06]
/usr/lib64/libQt6Core.so.6 QCoreApplication::notifyInternal2(QObject*, QEvent*) 0x137) [0x7f6f42cdfa87]
/usr/lib64/libQt6Core.so.6 QTimerInfoList::activateTimers() 0x43b) [0x7f6f42bf457b]
/usr/lib64/libQt6Core.so.6(+0xbe21c) [0x7f6f42abe21c]
/usr/lib64/libglib-2.0.so.0(+0x56e04) [0x7f6f3f725e04]
/usr/lib64/libglib-2.0.so.0(+0x59f27) [0x7f6f3f728f27]
/usr/lib64/libglib-2.0.so.0(g_main_context_iteration+0x30) [0x7f6f3f729540]
/usr/lib64/libQt6Core.so.6 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 0x70) [0x7f6f42abe3f0]
/usr/lib64/libQt6Core.so.6 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) 0x14a) [0x7f6f42d0974a]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xa4fd0) [0x5580c7139fd0]
/home/colin/ladybird/cmake-build-debug/libexec/../lib64/liblagom-core.so.0 Core::EventLoop::exec() 0x37) [0x7f6f412d4481]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xb59e7) [0x5580c714a9e7]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0x16fcb7) [0x5580c7204cb7]
/usr/lib64/libc.so.6(+0x260d0) [0x7f6f403660d0]
/usr/lib64/libc.so.6(__libc_start_main+0x89) [0x7f6f40366189]
/home/colin/ladybird/cmake-build-debug/libexec/WebContent(+0xa4425) [0x5580c7139425]
vpzomtrrfrt commented 1 month ago

looks like the position from click applies after the event handler, so although updating the value does set the position to 0, it's immediately overwritten