djpohly / dwl

dwm for Wayland - ARCHIVE: development has moved to Codeberg
https://codeberg.org/dwl/dwl
Other
1.93k stars 284 forks source link

Dwl segfaults when launching gource #359

Closed antoniocorbi closed 1 year ago

antoniocorbi commented 1 year ago

Info

dwl version: 0.4-rc2 wlroots version: 0.16@fe7e7a14

Description

Some times I show my students a tool like gource to graphically see the development in a project that uses git. Well, to my surprise the simple fact of launching gource from a terminal makes Dwl segfault and takes me back to the VT from where Dwl was launched.

BenJarg commented 1 year ago

Are you able to get a backtrace?

antoniocorbi commented 1 year ago

Are you able to get a backtrace?

I think so, using coredumpctl debug this is what I get:

Core was generated by `dwl -s somebar'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005608e0861575 in ?? ()
[Current thread is 1 (Thread 0x7f892c782940 (LWP 3124))]
>>> bt
#0  0x00005608e0861575 in  ()
#1  0x00005608e08615d0 in  ()
#2  0x00007f892d45cf6e in wl_signal_emit_mutable (signal=<optimized out>, data=0x5608e25be5c0) at ../wayland-1.21.0/src/wayland-server.c:2179
#3  0x00007f892d54348c in manager_handle_create_inhibitor (client=0x5608e25b5cc0, manager_resource=0x5608e25cde00, id=33, surface_resource=0x5608e25ca1e0) at ../types/wlr_idle_inhibit_v1.c:100
#4  0x00007f892ce774f6 in ffi_call_unix64 () at ../src/x86/unix64.S:104
#5  0x00007f892ce73f5e in ffi_call_int (cif=<optimized out>, fn=<optimized out>, rvalue=<optimized out>, avalue=<optimized out>, closure=<optimized out>) at ../src/x86/ffi64.c:673
#6  0x00007f892ce76b73 in ffi_call (cif=cif@entry=0x7ffc514aa290, fn=<optimized out>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0x7ffc514aa360) at ../src/x86/ffi64.c:710
#7  0x00007f892d45bada in wl_closure_invoke (closure=closure@entry=0x5608e258efa0, target=<optimized out>, target@entry=0x5608e25cde00,
opcode=opcode@entry=1, data=<optimized out>, data@entry=0x5608e25b5cc0, flags=2) at ../wayland-1.21.0/src/connection.c:1025
#8  0x00007f892d46001c in wl_client_connection_data (fd=<optimized out>, mask=<optimized out>, data=<optimized out>) at ../wayland-1.21.0/src/wayland-server.c:437
#9  0x00007f892d45e9e2 in wl_event_loop_dispatch (loop=0x5608e17a9190, timeout=timeout@entry=-1) at ../wayland-1.21.0/src/event-loop.c:1027
#10 0x00007f892d45f197 in wl_display_run (display=0x5608e17a90a0) at ../wayland-1.21.0/src/wayland-server.c:1431
#11 0x00005608e0865b3a in  ()
#12 0x00007f892d148290 in __libc_start_call_main (main=main@entry=0x5608e08653f7, argc=argc@entry=3, argv=argv@entry=0x7ffc514aa998) at
../sysdeps/nptl/libc_start_call_main.h:58
#13 0x00007f892d14834a in __libc_start_main_impl (main=0x5608e08653f7, argc=3, argv=0x7ffc514aa998, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffc514aa988) at ../csu/libc-start.c:381
#14 0x00005608e0860de5 in  ()

As additional information I've tried gource in Hyprland and it works as expected. If you think I can help providing another class of info, please, let me know.

sevz17 commented 1 year ago

Please compile dwl with debug info (-g3 -ggdb3) and send me the backtrace

If you think I can help providing another class of info, please, let me know.

Seeing the backtrace seems like it tries to create a idle inhibitor, AFAIK Xwayland apps cannot use that protocol, so how did you run gource natively on wayland, I tried and only able to run through Xwayland.

Also, there was a segfault related with idle inhibitor fixed with 9c155eefdc018f878ea6950e6bd383b985401339 and fac3b6f2cf7e2d5e9de2b0618a5a2ad2e0809b03 (both are part of rc2), so I have to ask, are you sure that you are running rc2 and not rc1? (I ask because https://github.com/djpohly/dwl/issues/356#issuecomment-1346646463).

antoniocorbi commented 1 year ago

Please compile dwl with debug info (-g3 -ggdb3) and send me the backtrace

If you think I can help providing another class of info, please, let me know.

Seeing the backtrace seems like it tries to create a idle inhibitor, AFAIK Xwayland apps cannot use that protocol, so how did you run gource natively on wayland, I tried and only able to run through Xwayland.

Probably because I launch dwl from a wrapper script setting some env variables, specially this:

export SDL_VIDEODRIVER=wayland

But even if I dont set that variable I still get the segfault.

By the way, Im using sdl2 2.26.1-1 from archlinux.

Also, there was a segfault related with idle inhibitor fixed with 9c155ee and fac3b6f (both are part of rc2), so I have to ask, are you sure that you are running rc2 and not rc1? (I ask because #356 (comment)).

Im on dwl main branch, latest commits I can show you i.e. are:

* 94c8bd6 - (HEAD -> main, origin/main) get `sel` from focustop() in focusstack() (hace 5 días) <Leonardo Hernández Hernández>
* c60f651 - Revert "force line-buffered stdout if stdout is not a tty" (hace 6 días) <Leonardo Hernández Hernández>
* 79b051f - (sicvs/main) implement ext-session-lock-v1 (hace 9 días) <Leonardo Hernández Hernández>
* d42a977 - Revert "remove unneeded changes in commitnotify()" (hace 9 días) <Leonardo Hernández Hernández>
* 4a32293 - Revert "fix flickering when resizing/spawning windows" (hace 9 días) <Leonardo Hernández Hernández>
* 9136b62 - return early if couldn't find the popup's parent (hace 9 días) <Leonardo Hernández Hernández>
* 19b5d47 - fix popups appearing outside the monitor (hace 9 días) <Leonardo Hernández Hernández>
* c9a0a8b - (tag: v0.4-rc2) bump version to 0.4-rc2 (hace 9 días) <Leonardo Hernández Hernández>

I have recompiled dwl from main branch using suggested -g3 -ggdb3 options and using wlroots-0.16 and after launching gource the backtrace I get is this one:

Core was generated by `dwl -s somebar'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055772b62f575 in checkidleinhibitor (exclude=exclude@entry=0x0) at dwl.c:630
630         if (bypass_surface_visibility || (exclude != surface
[Current thread is 1 (Thread 0x7f6165acb940 (LWP 91293))]
(gdb) bt
#0  0x000055772b62f575 in checkidleinhibitor (exclude=exclude@entry=0x0) at dwl.c:630
#1  0x000055772b62f5d0 in createidleinhibitor (listener=<optimized out>, data=<optimized out>) at dwl.c:779
#2  0x00007f61667a5f6e in wl_signal_emit_mutable (signal=<optimized out>, data=0x55772c2d9ac0) at ../wayland-1.21.0/src/wayland-server.c:2179
#3  0x00007f616688e48c in manager_handle_create_inhibitor (client=0x55772c023960, manager_resource=0x55772c0664b0, id=29, surface_resource=0x55772c2d0a40) at ../types/wlr_idle_inhibit_v1.c:100
#4  0x00007f61661c04f6 in ffi_call_unix64 () at ../src/x86/unix64.S:104
#5  0x00007f61661bcf5e in ffi_call_int (cif=<optimized out>, fn=<optimized out>, rvalue=<optimized out>, avalue=<optimized out>, closure=<optimized out>) at ../src/x86/ffi64.c:673
#6  0x00007f61661bfb73 in ffi_call (cif=cif@entry=0x7ffd7b3eb240, fn=<optimized out>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0x7ffd7b3eb310) at ../src/x86/ffi64.c:710
#7  0x00007f61667a4ada in wl_closure_invoke (closure=closure@entry=0x55772c067ce0, target=<optimized out>, target@entry=0x55772c0664b0, opcode=opcode@entry=1, data=<optimized out>, data@entry=0x55772c023960, flags=2) at ../wayland-1.21.0/src/connection.c:1025
#8  0x00007f61667a901c in wl_client_connection_data (fd=<optimized out>, mask=<optimized out>, data=<optimized out>) at ../wayland-1.21.0/src/wayland-server.c:437
#9  0x00007f61667a79e2 in wl_event_loop_dispatch (loop=0x55772b661190, timeout=timeout@entry=-1) at ../wayland-1.21.0/src/event-loop.c:1027
#10 0x00007f61667a8197 in wl_display_run (display=0x55772b6610a0) at ../wayland-1.21.0/src/wayland-server.c:1431
#11 0x000055772b633b41 in run (startup_cmd=0x7ffd7b3ebea3 "somebar") at dwl.c:1941
#12 main (argc=<optimized out>, argv=<optimized out>) at dwl.c:2781

This backtrace is obtained using SDL_VIDEODRIVER=wayland. As I said before, I can use gource in other wayland compositors like Hyprland and using exactly the same start-up wrapper script but changing the call to dwl to Hyprland.

By the way, the start-up script I use is this:

cd ~

export _JAVA_AWT_WM_NONREPARENTING=1
export XCURSOR_SIZE=24
export GTK_THEME=Catppuccin-Latte-Standard-Blue-Light
export SDL_VIDEODRIVER=wayland
export MOZ_ENABLE_WAYLAND=1

# Gtk settings
export gnomeschema=org.gnome.desktop.interface
gsettings set $gnomeschema gtk-theme    $GTK_THEME
gsettings set $gnomeschema icon-theme   'Delft-Blue'
gsettings set $gnomeschema cursor-theme 'Bibata-Modern-Ice'
gsettings set $gnomeschema font-name    'Carlito Bold 14'

# start-up services from shell that do not require the wayland
# compositor running
#
# emacs daemon
/usr/bin/emacs --bg-daemon &

LD_PRELOAD=/home/acorbi/projects/wlroots/build/libwlroots.so dwl -s 'somebar' &>/dev/null

Hope this helps.

sevz17 commented 1 year ago

Please compile dwl with debug info (-g3 -ggdb3) and send me the backtrace

If you think I can help providing another class of info, please, let me know.

Seeing the backtrace seems like it tries to create a idle inhibitor, AFAIK Xwayland apps cannot use that protocol, so how did you run gource natively on wayland, I tried and only able to run through Xwayland.

Probably because I launch dwl from a wrapper script setting some env variables, specially this:

export SDL_VIDEODRIVER=wayland

But even if I dont set that variable I still get the segfault.

By the way, Im using sdl2 2.26.1-1 from archlinux.

Unfortunately I get:

$ SDL_VIDEODRIVER=wayland gource
gource: SDL initialization failed - GLEW Error: Unknown error
Try 'gource --help' for more information.

I think it's because archlinux applies a patch that gentoo does not. Thus I will rely on you to provide more information :)

This backtrace is obtained using SDL_VIDEODRIVER=wayland. As I said before, I can use gource in other wayland compositors like Hyprland and using exactly the same start-up wrapper script but changing the call to dwl to Hyprland.

Can you send me the output of p *surface, p *inhibitor, p *tree and p *tree->node?

antoniocorbi commented 1 year ago

ok, lets try:

p *surface $1 = { resource = 0x5584a6a63480, renderer = 0x5584a60b66d0, buffer = 0x0, sx = 0, sy = 0, buffer_damage = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, external_damage = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, opaque_region = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, input_region = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, current = { committed = 0, seq = 0, buffer = 0x0, dx = 0, dy = 0, surface_damage = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, buffer_damage = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, opaque = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, input = { extents = { x1 = -2147483648, y1 = -2147483648, x2 = 2147483647, y2 = 2147483647 }, data = 0x0 }, transform = WL_OUTPUT_TRANSFORM_NORMAL, scale = 1, frame_callback_list = { prev = 0x5584a6941d60, next = 0x5584a6941d60 }, width = 0, height = 0, buffer_width = 0, buffer_height = 0, subsurfaces_below = { prev = 0x5584a6941d80, next = 0x5584a6941d80 }, subsurfaces_above = { prev = 0x5584a6941d90, next = 0x5584a6941d90 }, viewport = { has_src = false, has_dst = false, src = { x = 0, y = 0, width = 0, height = 0 }, dst_width = 0, dst_height = 0 }, cached_state_locks = 0, cached_state_link = { prev = 0x0, next = 0x0 } }, pending = { committed = 200, seq = 1, buffer = 0x0, dx = 0, dy = 0, surface_damage = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, buffer_damage = { extents = { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }, data = 0x7f21560e89d0 }, opaque = { extents = { x1 = 0, y1 = 0, x2 = 1024, y2 = 768 }, data = 0x0 }, input = { extents = { x1 = -2147483648, y1 = -2147483648, x2 = 2147483647, y2 = 2147483647 }, data = 0x0 }, transform = WL_OUTPUT_TRANSFORM_NORMAL, scale = 1, frame_callback_list = { prev = 0x5584a6a62f00, next = 0x5584a6a63380 }, width = 0, height = 0, buffer_width = 0, buffer_height = 0, subsurfaces_below = { prev = 0x5584a6941e88, next = 0x5584a6941e88 }, subsurfaces_above = { prev = 0x5584a6941e98, next = 0x5584a6941e98 }, viewport = { has_src = false, has_dst = false, src = { x = 0, y = 0, width = 0, height = 0 }, dst_width = 0, dst_height = 0 }, cached_state_locks = 0, cached_state_link = { prev = 0x0, next = 0x0 } }, cached = { prev = 0x5584a6941ef0, next = 0x5584a6941ef0 }, role = 0x0, role_data = 0x0, events = { client_commit = { listener_list = { prev = 0x5584a6941f10, next = 0x5584a6941f10 } }, commit = { listener_list = { prev = 0x5584a6941f20, next = 0x5584a6941f20 } }, new_subsurface = { listener_list = { prev = 0x5584a6941f30, next = 0x5584a6941f30 } }, destroy = { listener_list = { prev = 0x5584a6918da0, next = 0x5584a6918da0 } } }, current_outputs = { prev = 0x5584a6941f50, next = 0x5584a6941f50 }, addons = { addons = { prev = 0x5584a6953ce0, next = 0x5584a6953ce0 } }, data = 0x0, renderer_destroy = { link = { prev = 0x5584a6b46e58, next = 0x5584a60b66e0 }, notify = 0x7f215626cac8 }, previous = { scale = 0, transform = WL_OUTPUT_TRANSFORM_NORMAL, width = 0, height = 0, buffer_width = 0, buffer_height = 0 }, opaque = false }

p *inhibitor $3 = { surface = 0x5584a6941c60, resource = 0x5584a6a624c0, surface_destroy = { link = { prev = 0x5584a6941f40, next = 0x5584a6941f40 }, notify = 0x7f21562762f1 }, link = { prev = 0x5584a68b28c0, next = 0x5584a68b28c0 }, events = { destroy = { listener_list = { prev = 0x5584a43e2910 , next = 0x5584a43e2910 } } }, data = 0x0 }

p *tree Cannot access memory at address 0x0

p tree $4 = (struct wlr_scene_tree *) 0x0

So *tree->node does not make sense here.

Once again, thanks for your interest in this problem and all your help ;)

sevz17 commented 1 year ago

Once again, thanks for your interest in this problem and all your help ;)

You're welcome, glad I could help.

antoniocorbi commented 1 year ago

Once again, thanks for your interest in this problem and all your help ;)

You're welcome, glad I could help.

Yes! that patch makes it work! Thanks @sevz17