LadybirdBrowser / ancient-history

The Ladybird web browser
BSD 2-Clause "Simplified" License
1.62k stars 107 forks source link

Segmentation fault on ARM64 #56

Closed grav closed 1 year ago

grav commented 1 year ago

On Arch Linux ARM64, I get a Segmentation fault on a fresh checkout (2ebaaf5e5ce1c954e8c3e6bfb0c17cc0e412e1b6):

Building (with clang, since ldd+gcc results in build error):

$ git clone git@github.com:SerenityOS/ladybird.git
$ cd ladybird
$ cmake -GNinja -B Build -DCMAKE_CXX_COMPILER=clang++
$ cmake --build Build
$ ninja -C Build debug

Running (no window showing up, crashing immediately):


(gdb) run
Starting program: /home/grav/repo/ladybird/Build/ladybird 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0xfffff00eef00 (LWP 81829)]
[New Thread 0xffffe3ed1f00 (LWP 81830)]

Thread 1 "ladybird" received signal SIGSEGV, Segmentation fault.
is_function () at serenity/Userland/Libraries/LibJS/Runtime/Value.cpp:224
224    return is_object() && as_object().is_function();
(gdb) bt
#0  is_function () at serenity/Userland/Libraries/LibJS/Runtime/Value.cpp:224
#1  as_function () at serenity/Userland/Libraries/LibJS/Runtime/Value.cpp:229
#2  0x0000fffff5610260 in initialize_intrinsics () at serenity/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp:310
#3  0x0000fffff560ce28 in create () at serenity/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp:157
#4  0x0000fffff5664400 in create () at serenity/Userland/Libraries/LibJS/Runtime/Realm.cpp:24
#5  initialize_host_defined_realm () at serenity/Userland/Libraries/LibJS/Runtime/Realm.cpp:40
#6  0x0000fffff7a78a94 in main_thread_vm () at serenity/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp:308
#7  0x0000fffff7cc0eb0 in main_thread_event_loop () at serenity/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp:49
#8  0x0000fffff7b32550 in create_a_new_browsing_context () at serenity/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp:97
#9  0x0000fffff7c3aa9c in Page () at serenity/Userland/Libraries/LibWeb/Page/Page.cpp:16
#10 0x0000aaaaaaae4420 in make<Web::Page, HeadlessBrowserPageClient&> () at serenity/AK/NonnullOwnPtr.h:161
#11 HeadlessBrowserPageClient () at /home/grav/repo/ladybird/WebView.cpp:342
#12 create () at /home/grav/repo/ladybird/WebView.cpp:93
#13 WebView () at /home/grav/repo/ladybird/WebView.cpp:362
#14 0x0000aaaaaaaeca18 in Tab () at /home/grav/repo/ladybird/Tab.cpp:28
#15 0x0000aaaaaaad4e18 in make<Tab, BrowserWindow*> () at serenity/AK/NonnullOwnPtr.h:161
#16 new_tab () at /home/grav/repo/ladybird/BrowserWindow.cpp:213
#17 0x0000aaaaaaad4ccc in BrowserWindow () at /home/grav/repo/ladybird/BrowserWindow.cpp:199
#18 0x0000aaaaaaae3e84 in serenity_main () at /home/grav/repo/ladybird/main.cpp:33
#19 0x0000fffff75616b0 in main () at serenity/Userland/Libraries/LibMain/Main.cpp:39
ADKaster commented 1 year ago

I don't have an arm machine handy, but I'm curious, could you try passing -DBUILDSHARED,LIBS=OFF to CMake? I ran into similar issues trying to build for Android

grav commented 1 year ago

Thanks, @ADKaster Tried

$ cmake -GNinja -B Build -DCMAKE_CXX_COMPILER=clang++  -DBUILD_SHARED_LIBS=OFF
$ cmake --build Build
$ ninja -C Build debug

but it gives me the same crash.

ricardonunosr commented 1 year ago

@grav I was able to get ladybird building in my M1 mac (arm64). I just needed to edit the Ninja build script to use lldb(mac alternative) instead of gdb because i think gdb still doenst support arm64 afaik.

grav commented 1 year ago

I just needed to edit the Ninja build script to use lldb(mac alternative) instead of gdb because i think gdb still doenst support arm64 afaik.

Thanks @ricardonunosr Not knowing a lot about C toolchains, can you point me to where you did the edit?

Cheers, Mikkel

ricardonunosr commented 1 year ago

Yes ofc @grav , when you do a build just go into the Build folder then build.ninja file then search for gdb and switch to lldb. I think the cmake script should make this automatically but not sure. Let me know if it works 👍

AaronDewes commented 1 year ago

I can reproduce the same issue and switching the debugger won't help. On arm64 Linux, gdb works, but the issue can be reproduced without a debugger.

BertalanD commented 1 year ago

I triaged the bug and opened a Serenity issue about it: https://github.com/SerenityOS/serenity/issues/15290

grav commented 1 year ago

Awesome! One more browser for Linux ARM64 (looking at you, Chrome!)