atlas-engineer / nyxt

Nyxt - the hacker's browser.
https://nyxt-browser.com/
9.64k stars 404 forks source link

Nyxt crashes when changing buffers repeatedly #3393

Closed lmcj-xyz closed 1 week ago

lmcj-xyz commented 1 month ago

Describe the bug Switching buffers makes the browser eventually crash, this happens regardless of the amount of buffers open.

It's triggered more easily when switching rapidly, say to load the buffers that were open in a previous session. No idea if this means it's loading something extra when switching and this corrupts memory in some way? The terminal output doesn't reflect that.

In the "Output from terminal" you will notice that it complains of not being able to create /home/lmcj/.var/app/engineer.atlas.Nyxt/cache, however when I look for it the directory exists and within it there are three directories, namely fontconfig, mesa_shader_cache and tmp. Also, it complains about it every time it's loading a buffer.

You will also see in the output from terminal that I loaded 3 buffers, this was a result of me changing buffers which were loaded from the history, once the buffers were loaded I continued changing buffers, naturally no more loading was done, but then suddenly the last part of the output is printed, which is when it crashed.

Precise recipe to reproduce the issue

  1. Open Nyxt
  2. Open a few buffers
  3. Change buffers repeatedly

For website-specific issues: N/A

Information

ASDF version: 3.3.1 ASDF registries: (NYXT-SOURCE-REGISTRY ENVIRONMENT-SOURCE-REGISTRY) Critical dependencies: (/run/build/nyxt/_build/cl-cffi-gtk/gtk/cl-cffi-gtk.asd /run/build/nyxt/_build/cl-gobject-introspection/cl-gobject-introspection.asd /run/build/nyxt/_build/cl-webkit/webkit2/cl-webkit2.asd)


**Output when started from a shell**

Nyxt version 3.11.6

[12:23:23] Source location: #P"/app/share/nyxt/" [12:23:23] Listening to socket: #P"/run/user/1000/nyxt/nyxt.socket" [12:23:24] Loading #P"/home/lmcj/.local/share/nyxt/history/default.lisp". [12:23:24] Restoring 4 buffers from history. Failed to create /home/lmcj/.var/app/engineer.atlas.Nyxt/cache for shader cache (No existe el fichero o el directorio)---disabling. Failed to create /home/lmcj/.var/app/engineer.atlas.Nyxt/cache for shader cache (No existe el fichero o el directorio)---disabling. [12:23:26] Loading #P"/home/lmcj/.local/share/nyxt/auto-rules.lisp". Failed to create /home/lmcj/.var/app/engineer.atlas.Nyxt/cache for shader cache (No existe el fichero o el directorio)---disabliFailed to create /home/lmcj/.var/app/engineer.atlas.Nyxt/cache for shader cache (No existe el fichero o el directorio)---disabling. ng. [12:23:40] Loading "https://luevano.xyz/". [12:23:41] Finished loading "https://luevano.xyz/". Failed to create /home/lmcj/.var/app/engineer.atlas.Nyxt/cache for shader cache (No existe el fichero o el directorio)---disabling. [12:23:44] Loading "https://lmcj.xyz/stats-seminar/". [12:23:44] Finished loading "https://lmcj.xyz/stats-seminar/". Failed to create /home/lmcj/.var/app/engineer.atlas.Nyxt/cache for shader cache (No existe el fichero o el directorio)---disabling. (nyxt:2): Gdk-CRITICAL **: 12:24:13.505: gdk_window_create_gl_context: assertion 'GDK_IS_WINDOW (window)' failed CORRUPTION WARNING in SBCL pid 2 tid 15: Memory fault at 0x8 (pc=0x7fd07058cb48, fp=0x7fd089ffde50, sp=0x7fd089ffde30) tid 15 The integrity of this image is possibly compromised. Continuing with fingers crossed. [12:24:13] Warning: Error on GI-GTK thread: Unhandled memory fault at #x8. ; ; compilation unit aborted ; caught 1 fatal ERROR condition ```
aadcg commented 1 month ago

I can't reproduce it but I'll keep an eye on it. Try to run flatpak update in the meantime as it may update some dependencies.

fictitiousexistence commented 1 month ago

Running into the same issue with crashing (but not having the failure to create cache issue).

Built from source. Happened on 3.11.6, downgraded to 3.11.4 with sbcl 2.3.5 and it occured again. Tried with latest git clone and got the same crash.

Nyxt version: 3.11.6
Renderer: GI-GTK
Operating system kernel: Linux 6.8.8-gentoo
Lisp implementation: SBCL 2.4.3 (Dynamic space size: 3221225472)
Features: (:NYXT-GI-GTK :NYXT-GTK :NYXT-GI-GTK :NYXT-GTK :NYXT-3.11 :NYXT-3 :NYXT-3.11.6
 :CLIPBOARD-CONTENT-METHOD :SWANK :SLYNK :PLUMP-UTF-32 :PARENSCRIPT :NSYMBOLS
 :FSET-EXT-STRINGS :SBCL+SAFE-STANDARD-READTABLE :NAMED-READTABLES :GLOBAL-VARS
 :CL-FAD :LPARALLEL :21BIT-CHARS :CUSTOM-HASH-TABLE-NATIVE :CL-PPCRE-UNICODE
 :CL-UNICODE :CL-JSON-DOUBLE-FLOAT-IS-SUBSUMED
 :CL-JSON-SINGLE-FLOAT-IS-SUBSUMED :CHUNGA :FLEXI-STREAMS :CL-PPCRE :WEBKIT2
 :WEBKIT-2.44.1 :WEBKIT-2.44 :WEBKIT-2 :WEBKIT2-CORS-ALLOWLIST
 :WEBKIT2-PASTE-PLAINTEXT :WEBKIT2-TRACKING :WEBKIT2-MUTE :WEBKIT2-EMOJI
 :WEBKIT2-MEDIA :WEBKIT2-SANDBOXING :GTK-3-22 :GTK-3-20 :GTK-3-18 :GTK-3-16
 :GTK-3-14 :GTK-3-12 :GTK-3-10 :GTK-3-8 :GTK-3-6 :GTK-3-4 :GTK :GDK-3-22
 :GDK-3-20 :GDK-3-18 :GDK-3-16 :GDK-3-14 :GDK-3-12 :GDK-3-10 :GDK-3-8 :GDK-3-6
 :GDK-3-4 :CAIRO-1-10 :CAIRO-1-12 :GDK-PIXBUF :CLOSER-MOP :GLIB-2-30 :GLIB-2-32
 :GLIB-2-34 :GLIB-2-36 :GLIB-2-38 :GLIB-2-40 :GLIB-2-42 :GLIB-2-44 :GLIB-2-46
 :GLIB-2-48 :GLIB-2-50 :GLIB-2-52 :GLIB-2-54 :GLIB-2-56 :GLIB-2-58 :GLIB
 :BORDEAUX-THREADS :LPARALLEL.WITH-CLTL2 :LPARALLEL.WITH-CAS
 :LPARALLEL.WITH-STEALING-SCHEDULER :SPLIT-SEQUENCE
 CFFI-FEATURES:FLAT-NAMESPACE CFFI-FEATURES:X86-64 CFFI-FEATURES:UNIX :CFFI
 CFFI-SYS::FLAT-NAMESPACE ALEXANDRIA::SEQUENCE-EMPTYP :FAST-IO-SV :FAST-IO
 :CL-JSON-CLOS :CL-JSON :SBCL-USES-SB-ROTATE-BYTE CHIPZ-SYSTEM:GRAY-STREAMS
 :THREAD-SUPPORT :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF :OS-UNIX
 :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :ARENA-ALLOCATOR :X86-64 :GENCGC :64-BIT
 :ANSI-CL :COMMON-LISP :ELF :IEEE-FLOATING-POINT :LINUX :LITTLE-ENDIAN
 :PACKAGE-LOCAL-NICKNAMES :SB-CORE-COMPRESSION :SB-LDB :SB-PACKAGE-LOCKS
 :SB-THREAD :SB-UNICODE :SBCL :UNIX)
(nyxt:11822): Gdk-CRITICAL **: 11:42:59.938: gdk_window_create_gl_context: assertion 'GDK_IS_WINDOW (window)' failed
CORRUPTION WARNING in SBCL pid 11822 tid 11848:
Memory fault at 0x8 (pc=0x7efe465f6bb8, fp=0x7efe2c765eb0, sp=0x7efe2c765eb0) tid 11848
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
Backtrace for: #<SB-THREAD:THREAD tid=11848 "Nyxt renderer thread" RUNNING {10082969E3}>
0: ("bogus stack frame")
1: ((LAMBDA (&REST GIR::ARGS-IN) :IN GIR::BUILD-FUNCTION))
2: ((FLET NYXT/RENDERER/GI-GTK::MAIN-FUNC :IN NYXT:FFI-INITIALIZE))
3: ((LAMBDA NIL :IN BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS))
4: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
5: ((FLET "WITHOUT-INTERRUPTS-BODY-156" :IN SB-THREAD::RUN))
6: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
7: ((FLET "WITHOUT-INTERRUPTS-BODY-149" :IN SB-THREAD::RUN))
8: (SB-THREAD::RUN)
9: ("foreign function: call_into_lisp_")
10: ("foreign function: funcall1")
 <WARN> [11:42:59] nyxt message.lisp (echo-warning form-fun-5) -
  Warning: Error on GI-GTK thread: Unhandled memory fault at #x8.
<DEBUG> [11:42:59] nyxt urls.lisp (lisp-url with-recursive-lock-thunk) - Registering callback 20587 for buffer #<STATUS-BUFFER 6959 {1006C29A33}>

Nyxt version: 3.11.4
Renderer: GI-GTK
Operating system kernel: Linux 6.8.8-gentoo
Lisp implementation: SBCL 2.3.5 (Dynamic space size: 3221225472)
Features: (:NYXT-GI-GTK :NYXT-GTK :NYXT-GI-GTK :NYXT-GTK :NYXT-3.11 :NYXT-3 :NYXT-3.11.4
 :CLIPBOARD-CONTENT-METHOD :SWANK :SLYNK :PLUMP-UTF-32 :PARENSCRIPT :NSYMBOLS
 :FSET-EXT-STRINGS :SBCL+SAFE-STANDARD-READTABLE :NAMED-READTABLES :GLOBAL-VARS
 :CL-FAD :LPARALLEL :21BIT-CHARS :CUSTOM-HASH-TABLE-NATIVE :CL-PPCRE-UNICODE
 :CL-UNICODE :CL-JSON-DOUBLE-FLOAT-IS-SUBSUMED
 :CL-JSON-SINGLE-FLOAT-IS-SUBSUMED :CHUNGA :FLEXI-STREAMS :CL-PPCRE :WEBKIT2
 :WEBKIT-2.44.1 :WEBKIT-2.44 :WEBKIT-2 :WEBKIT2-CORS-ALLOWLIST
 :WEBKIT2-PASTE-PLAINTEXT :WEBKIT2-TRACKING :WEBKIT2-MUTE :WEBKIT2-EMOJI
 :WEBKIT2-MEDIA :WEBKIT2-SANDBOXING :GTK-3-22 :GTK-3-20 :GTK-3-18 :GTK-3-16
 :GTK-3-14 :GTK-3-12 :GTK-3-10 :GTK-3-8 :GTK-3-6 :GTK-3-4 :GTK :GDK-3-22
 :GDK-3-20 :GDK-3-18 :GDK-3-16 :GDK-3-14 :GDK-3-12 :GDK-3-10 :GDK-3-8 :GDK-3-6
 :GDK-3-4 :CAIRO-1-10 :CAIRO-1-12 :GDK-PIXBUF :CLOSER-MOP :GLIB-2-30 :GLIB-2-32
 :GLIB-2-34 :GLIB-2-36 :GLIB-2-38 :GLIB-2-40 :GLIB-2-42 :GLIB-2-44 :GLIB-2-46
 :GLIB-2-48 :GLIB-2-50 :GLIB-2-52 :GLIB-2-54 :GLIB-2-56 :GLIB-2-58 :GLIB
 :BORDEAUX-THREADS :LPARALLEL.WITH-CLTL2 :LPARALLEL.WITH-CAS
 :LPARALLEL.WITH-STEALING-SCHEDULER :SPLIT-SEQUENCE
 CFFI-FEATURES:FLAT-NAMESPACE CFFI-FEATURES:X86-64 CFFI-FEATURES:UNIX :CFFI
 CFFI-SYS::FLAT-NAMESPACE ALEXANDRIA::SEQUENCE-EMPTYP :FAST-IO-SV :FAST-IO
 :CL-JSON-CLOS :CL-JSON :SBCL-USES-SB-ROTATE-BYTE CHIPZ-SYSTEM:GRAY-STREAMS
 :THREAD-SUPPORT :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF :OS-UNIX
 :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :ARENA-ALLOCATOR :X86-64 :GENCGC :64-BIT
 :ANSI-CL :COMMON-LISP :ELF :IEEE-FLOATING-POINT :LINUX :LITTLE-ENDIAN
 :PACKAGE-LOCAL-NICKNAMES :SB-CORE-COMPRESSION :SB-LDB :SB-PACKAGE-LOCKS
 :SB-THREAD :SB-UNICODE :SBCL :UNIX)
(nyxt:19646): Gdk-CRITICAL **: 11:47:15.811: gdk_window_create_gl_context: assertion 'GDK_IS_WINDOW (window)' failed
CORRUPTION WARNING in SBCL pid 19646 tid 19671:
Memory fault at 0x8 (pc=0x7f465b2c2bb8, fp=0x7f464106deb0, sp=0x7f464106deb0) tid 19671
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
Backtrace for: #<SB-THREAD:THREAD tid=19671 "Nyxt renderer thread" RUNNING {100821DF33}>
0: ("bogus stack frame")
1: ((LAMBDA (&REST GIR::ARGS-IN) :IN GIR::BUILD-FUNCTION))
2: ((FLET NYXT/RENDERER/GI-GTK::MAIN-FUNC :IN NYXT:FFI-INITIALIZE))
3: ((LAMBDA NIL :IN BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS))
4: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
5: ((FLET "WITHOUT-INTERRUPTS-BODY-156" :IN SB-THREAD::RUN))
6: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
7: ((FLET "WITHOUT-INTERRUPTS-BODY-149" :IN SB-THREAD::RUN))
8: (SB-THREAD::RUN)
9: ("foreign function: call_into_lisp_")
10: ("foreign function: funcall1")
 <WARN> [11:47:15] nyxt message.lisp (echo-warning form-fun-5) -
  Warning: Error on GI-GTK thread: Unhandled memory fault at #x8.
<DEBUG> [11:47:15] nyxt urls.lisp (lisp-url with-recursive-lock-thunk) - Registering callback 16242 for buffer #<STATUS-BUFFER 6957 {1006C30633}>
aadcg commented 1 month ago

@fictitiousexistence that seems to suggest that the issue may be related to a new WebKitGTK version.

fictitiousexistence commented 1 month ago

@aadcg Thank you. Gentoo updated from webkit 2.42.5 to 2.44.1 and dropped 2.42.5. I rebuilt 2.42.5 and confirmed it no longer happens. I couldn't get anything between those 2 versions to build so I'm not sure when it started.

Is this completly different from original issue here and not a nyxt issue but strictly webkit-gtk and a bug should be filed over there?

aadcg commented 1 month ago

@fictitiousexistence the error reported here seems to be related to webkitgtk alone. Nyxt seems to be running fine on Flatpak, which is using webkitgtk 2.44.0.

In order to report a bug to webkitgtk, we'd need to understand what exactly is going on, i.e. it may be related to https://github.com/joachifm/cl-webkit or webkitgtk itself.

antrmn commented 1 month ago

I'm experiencing a similar issue on OpenSUSE Tumbleweed. No matter if i use the .rpm or the .flatpak: switching buffers repeatedly (or even randomly) causes Nyxt to crash. I have no custom config installed.

This is the output from the flatpak:

Nyxt version 3.11.6
<INFO> [13:49:16] Source location: #P"/app/share/nyxt/"
<INFO> [13:49:16] Listening to socket: #P"/run/user/1000/nyxt/nyxt.socket"
<INFO> [13:49:17] Loading #P"/home/antonio/.local/share/nyxt/history/default.lisp".
<INFO> [13:49:17] Restoring 11 buffers from history.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
<INFO> [13:49:17] Loading #P"/home/antonio/.local/share/nyxt/auto-rules.lisp".
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
<INFO> [13:49:19] Loading "https://www.google.com/search?q=<<omitted>>".
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
<INFO> [13:49:20] Finished loading "https://www.google.com/search?q=<<omitted>>".
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
<WARN> [13:49:26] Warning: Error while processing the "nyxt:" URL: Required argument NYXT:CALLBACK missing.
<INFO> [13:49:27] Failed to load URL nyxt:new in buffer 5802.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.

(nyxt:2): Gtk-CRITICAL **: 13:49:28.184: gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed

(nyxt:2): Gtk-CRITICAL **: 13:49:28.184: gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed

(nyxt:2): Gtk-CRITICAL **: 13:49:28.184: gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed

(nyxt:2): Gtk-CRITICAL **: 13:49:28.184: gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed

(nyxt:2): Gtk-CRITICAL **: 13:49:28.184: gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed
<WARN> [13:49:28] Warning: Error while processing the "nyxt:" URL: Required argument NYXT:CALLBACK missing.
<INFO> [13:49:28] Failed to load URL nyxt:nyxt/mode/buffer-listing:list-buffers?cluster=%1Bnil&linear-view-p=%1Bnil in buffer 5826.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
Failed to create /home/antonio/.var/app/engineer.atlas.Nyxt/cache for shader cache (No such file or directory)---disabling.
<INFO> [13:49:29] Loading "https://github.com/atlas-engineer/nyxt/issues/631".
<INFO> [13:49:29] Loading "https://search.atlas.engineer/searxng/search?q=nyxt".

(nyxt:2): Gtk-CRITICAL **: 13:49:29.721: gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed
<WARN> [13:49:29] Warning: Error while processing the "nyxt:" URL: There is no applicable method for the generic function #&lt;STANDARD-GENERIC-FUNCTION NYXT:STYLE (17)&gt; when called with arguments (NIL).
See also:
  The ANSI Standard, Section 7.6.6
<INFO> [13:49:29] Failed to load URL nyxt:nyxt/mode/history:buffer-history-tree?id=%1B16740 in buffer 5864.

(nyxt:2): Gtk-CRITICAL **: 13:49:30.105: gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed

(nyxt:2): Gtk-CRITICAL **: 13:49:30.645: gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed

(nyxt:2): Gdk-CRITICAL **: 13:49:30.785: gdk_window_create_gl_context: assertion 'GDK_IS_WINDOW (window)' failed
CORRUPTION WARNING in SBCL pid 2 tid 19:
Memory fault at 0x8 (pc=0x7f3bd058cb48, fp=0x7f3be47fde50, sp=0x7f3be47fde30) tid 19
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
<WARN> [13:49:30] Warning: Error on GI-GTK thread: Unhandled memory fault at #x8.
; 
; 
; compilation unit aborted
; compilation unit aborted
; compilation unit aborted
;   caught 1 fatal ERROR condition
;   caught 1 fatal ERROR condition
antonio@localhost:~> 
lugeha commented 1 month ago

Are you using Wayland GNOME? I get crashes all over the place using Niri.

gdk_window_create_gl_context: assertion 'GDK_IS_WINDOW (window)' failed

Trying to access internal documentation pages, and when restore history is enabled, or just random tab changes. These crashes go away when I run it in an X.org session or inside Xwayland. A quick search would indicate there is a bug with GTK3/Wayland interaction.

I have tried different versions of webkitgtk, nyxt, cl-webkit2, flatpaks, etc. All have the same issue, but only when on Wayland.

Update 1:

LIBGL_ALWAYS_SOFTWARE=1 makes crashes go away too. I'm using this on a laptop with NVIDIA prime. If I force offloading DRI_PRIME=1, this also fixes the crashes for me. I can test how it behaves for me on an AMD GPU a bit later.

Update 2:

Crashes out with AMD GPU as well. Running with EGL_LOG_LEVEL=debug spits out a bunch of this error

libEGL debug: EGL user error 0x300d (EGL_BAD_SURFACE) in eglSwapInterval

Looks to be a threading issue.

Update 3:

Disabling composting makes fixed it too.

WEBKIT_DISABLE_COMPOSITING_MODE=1

aadcg commented 4 weeks ago

@lugeha, indeed, it is documented in the manual to set that variable when the renderer misbehaves.

Can someone reproduce any of the issues mentioned after setting the mentioned environment variable?

fictitiousexistence commented 4 weeks ago

@aadcg Upgraded webkit back to 2.44.1. Added WEBKIT_DISABLE_COMPOSITING_MODE=1 Have been running for a couple hours without crashing.

lugeha commented 4 weeks ago

@aadcg to be fair, it only really mentions blank pages, not hard crashes.

lugeha commented 3 weeks ago

I just came across a possible explenation.

https://mail.gnu.org/archive/html/bug-gnu-emacs/2023-09/msg01905.html

WebkitGTK have removed offscreen rendering. It's broken xwidget-webkit as well.

oreo639 commented 1 week ago

Btw, this bug was reported upstream in March: https://bugs.webkit.org/show_bug.cgi?id=271477

Also the crash afterwards is caused by a nullptr dereference in libwebkit2gtk: https://github.com/WebKit/WebKit/blob/webkitgtk-2.44.2/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp#L537

The error happens because the webkit wiget doesn't have a realized window when gdk_window_create_gl_context() is being called, but as for what changed between 2.42.x and 2.44.x to cause this to happen, I'm not sure yet.

@lugeha It's unrelated.

aadcg commented 1 week ago

@aadcg to be fair, it only really mentions blank pages, not hard crashes.

See 0c3b71ae5.


@lugeha It's unrelated.

Correct!

@oreo639 thanks for your investigation. Closing since the bug is coming from WebKitGTK.