LadybirdBrowser / ancient-history

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

Crash on startup #15

Closed diegoiast closed 2 years ago

diegoiast commented 2 years ago

I am building the project on Debian/Testing (Using Qt5, a PR will follow "soon", as it is quite possible and not intrusive). Compiler is gcc (Debian 11.3.0-3) 11.3.0

I traced the crash here: https://github.com/awesomekling/ladybird/blob/d216df5da1d5e806823207be68dc8aeb68a646ce/WebView.cpp#L277

The assertion is:

ladybird: /home/diego/src/github/ladybird/build/serenity/AK/Error.h:97: T AK::ErrorOr<T, ErrorType>::release_value_but_fixme_should_propagate_errors() [with T = AK::NonnullRefPtr<Gfx::Bitmap>; ErrorType = AK::Error]: Assertion `!is_error()' failed.

Full backtrace:

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007ffff5049546 in __GI_abort () at abort.c:79
#2  0x00007ffff504942f in __assert_fail_base (fmt=0x7ffff51bfdf8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7ffff7d10987 "!is_error()", file=0x7ffff7d0ff88 "/home/diego/src/github/ladybird/build/serenity/AK/Error.h", line=97, 
    function=<optimized out>) at assert.c:92
#3  0x00007ffff5058222 in __GI___assert_fail (assertion=0x7ffff7d10987 "!is_error()", file=0x7ffff7d0ff88 "/home/diego/src/github/ladybird/build/serenity/AK/Error.h", line=97, 
    function=0x7ffff7d0fef8 "T AK::ErrorOr<T, ErrorType>::release_value_but_fixme_should_propagate_errors() [with T = AK::NonnullRefPtr<Gfx::Bitmap>; ErrorType = AK::Error]") at assert.c:101
#4  0x00007ffff7838438 in AK::ErrorOr<AK::NonnullRefPtr<Gfx::Bitmap>, AK::Error>::release_value_but_fixme_should_propagate_errors (this=0x7fffffffd4d0) at /home/diego/src/github/ladybird/build/serenity/AK/Error.h:95
#5  AK::ErrorOr<AK::NonnullRefPtr<Gfx::Bitmap>, AK::Error>::release_value_but_fixme_should_propagate_errors (this=0x7fffffffd4d0) at /home/diego/src/github/ladybird/build/serenity/AK/Error.h:95
#6  Web::FrameLoader::FrameLoader (this=0x5555556c1ab0, browsing_context=...) at /home/diego/src/github/ladybird/build/serenity/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp:41
#7  Web::FrameLoader::FrameLoader (this=this@entry=0x5555556c1ab0, browsing_context=...) at /home/diego/src/github/ladybird/build/serenity/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp:37
#8  0x00007ffff7791f9b in Web::HTML::BrowsingContext::BrowsingContext (this=this@entry=0x5555556c1a70, page=..., container=container@entry=0x0) at /home/diego/src/github/ladybird/build/serenity/AK/RefPtr.h:216
#9  0x00007ffff785d939 in Web::HTML::BrowsingContext::create (page=...) at /home/diego/src/github/ladybird/build/serenity/Userland/Libraries/LibWeb/HTML/BrowsingContext.h:28
#10 Web::Page::Page (this=0x5555556c1e00, client=...) at /home/diego/src/github/ladybird/build/serenity/Userland/Libraries/LibWeb/Page/Page.cpp:15
#11 0x0000555555564da9 in AK::make<Web::Page, HeadlessBrowserPageClient&> () at /home/diego/src/github/ladybird/build/serenity/AK/NonnullOwnPtr.h:161
#12 HeadlessBrowserPageClient::HeadlessBrowserPageClient (view=..., this=0x5555556c2130) at /home/diego/src/github/ladybird/WebView.cpp:277
#13 HeadlessBrowserPageClient::create (view=...) at /home/diego/src/github/ladybird/WebView.cpp:67
#14 WebView::WebView (this=this@entry=0x55555563ae10) at /home/diego/src/github/ladybird/WebView.cpp:293
#15 0x000055555556ddde in Tab::Tab (this=this@entry=0x5555556bd3d0, window=window@entry=0x7fffffffd870) at /home/diego/src/github/ladybird/Tab.cpp:22
#16 0x00005555555609a9 in AK::make<Tab, BrowserWindow*> () at /home/diego/src/github/ladybird/build/serenity/AK/NonnullOwnPtr.h:161
#17 BrowserWindow::new_tab (this=0x7fffffffd870) at /home/diego/src/github/ladybird/BrowserWindow.cpp:47
#18 0x000055555556103f in BrowserWindow::BrowserWindow (this=0x7fffffffd870, event_loop=...) at /home/diego/src/github/ladybird/BrowserWindow.cpp:40
#19 0x0000555555564489 in serenity_main (arguments=...) at /home/diego/src/github/ladybird/main.cpp:31
#20 0x00007ffff7f9917a in main (argc=argc@entry=1, argv=argv@entry=0x7fffffffdf38) at /home/diego/src/github/ladybird/build/serenity/Userland/Libraries/LibMain/Main.cpp:39
#21 0x00007ffff504a7fd in __libc_start_main (main=0x7ffff7f99120 <main(int, char**)>, argc=1, argv=0x7fffffffdf38, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdf28) at ../csu/libc-start.c:332
#22 0x000055555555ee6a in _start ()
julidau commented 2 years ago

This error actually occures in FrameLoader.cpp:41, as the FrameLoader tries to load the default icon and failes to do so.

The logic for finding the Serenity source dir can be found here

https://github.com/awesomekling/ladybird/blob/d216df5da1d5e806823207be68dc8aeb68a646ce/WebView.cpp#L53-L61

For me exporting SERENITY_SOURCE_DIR to the absolute build dir/serenity fixed this crash. Incidentially this is done by cmakes' run target automatically here

https://github.com/awesomekling/ladybird/blob/d216df5da1d5e806823207be68dc8aeb68a646ce/CMakeLists.txt#L52-L55

So using ninja -C Build run should "just work"

diegoiast commented 2 years ago

Solution for QtCreator:

  1. Make sure that Working directory in the Run configuration is set to %{buildDir}
  2. Inside QtCreator, Projects sub tab, Open the environment pane, add a new variable called SERENITY_SOURCE_DIR and set it to serenity.

You should be able to run and debug from QtCreator. I am aware that using a relative path (in step 2) may be considered "hacky" - but I am working on a solution to overcome this (I have some ideas, but it requires a smallish refactoring to the code).