swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.69k stars 1.11k forks source link

Sway dies when unplugging a Thunderbolt3 dock #2714

Closed ossimoi closed 6 years ago

ossimoi commented 6 years ago

Running sway version 1.0-alpha.6-47-gc43374cd on Gentoo Linux. Connecting a Thunderbolt 3 dock with external monitor and other peripherals works, but unplugging the dock makes sway crash (without core dump). I can get swaybg to dump if I do this with wallpaper set.

Sway crash log (without swaybg): https://pastebin.com/iT1TqYvi

Swaybg core dump: https://pastebin.com/w5TmPPnQ

Also worth mentioning that nothing crashes if I suspend the machine before unplugging the dock and resume right after.

emersion commented 6 years ago

makes sway crash (without core dump)

Eh. It's probably because it's got the suid bit set. Can you try installing elogind, unsetting the suid bit on the sway binary and try again?

You could also probably start sway, connect to your system with SSH, attaching GDB to the sway session via SSH, undock it and get the backtrace via the SSH connection.

ossimoi commented 6 years ago

Ah, of course. Linux is hard :)

Here's the dump: https://pastebin.com/zTzYx17w

rubdos commented 6 years ago

I have the same issue (intermittently) on my Thinkpad dock. Unplugging other monitors seems fine.

ossimoi commented 6 years ago

It looks like there's some kind of a bus reset, because eDP-1 (laptops internal monitor) gets destroyed as well.

https://github.com/swaywm/sway/issues/2337 might actually fix this?

emersion commented 6 years ago

2337 might actually fix this?

Unlikely. This issue is kind of weird, because what happens is basically:

It seems that the wlr_drm_connector gets free'd (or at least has invalid data) by the time we get the pageflip event. It's weird because even if you disconnect an output we keep the wlr_drm_connector around. Maybe it's because the connector goes away (it's not just disconnected), but in this case this should probably cancel the pageflip? I'm confused.

sydneymeyer commented 6 years ago

Another crash log: sway2.log

Sway version 1.0-alpha.6-43-ga032925a (Sep 24 2018, branch 'master')

ossimoi commented 6 years ago

Managed to unplug today withou crashing, only once though.

emersion commented 6 years ago

Can you try https://github.com/swaywm/wlroots/pull/1268 and say if it fixes your issue?

ossimoi commented 6 years ago

Unplugging works now, but replugging causes a crash.

https://pastebin.com/Yq30MLGh

emersion commented 6 years ago

Can you run it with valgrind and paste the logs here?

ossimoi commented 6 years ago

Took like 5 replug cycles to get a crash.

https://pastebin.com/Ew6xWpQv

emersion commented 6 years ago

It's weird because the stack trace (https://pastebin.com/Yq30MLGh) doesn't match with the Valgrind one (https://pastebin.com/Ew6xWpQv).

Can you try again to get a stack trace via coredumpctl gdb, and run bt full?

sydneymeyer commented 6 years ago

I can reliably get sway to crash everytime when unplugging from dock, even with https://github.com/swaywm/sway/issues/2337.

emersion commented 6 years ago

I can reliably get sway to crash everytime when unplugging from dock, even with #2337.

You probably mean swaywm/wlroots#1268?

Please always include a debug log and a stack trace. It doesn't help a lot to know that "it crashes".

sydneymeyer commented 6 years ago

You probably mean

swaywm/wlroots#1268?

Yes, my bad.

Please always include a debug log and a stack

trace.

I'll try and come back.

ossimoi commented 6 years ago

Updated sway to 1.0-alpha.6-105-g51f68e10

Valgrind and gdb dumps: https://pastebin.com/k4kqS4vR

ossimoi commented 6 years ago

Seems to be fixed, thank you!