Bug 438509

Summary: Segfault in open window when opening a new window
Product: [Applications] kate Reporter: Tcll <tcll5850>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: christoph, waqar.17a
Priority: NOR    
Version First Reported In: 21.04.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Insight-gdb moment of kate crash

Description Tcll 2021-06-12 15:08:32 UTC
SUMMARY
When a Kate instance is running, running a new instance of Kate will cause the existing instance to segfault before the new instance opens.


STEPS TO REPRODUCE
1. Open any text file in Kate (`-n` from file manager or command)
2. Open another text file in Kate (`-n` from file manager or command)
3. The previous window should close before the new window opens.

OBSERVED RESULT
When running the command to create an instance,
Creating another instance causes the initial instance to close with:
"Segmentation fault"
while the 2nd instance replaces the first.

EXPECTED RESULT
2 windows should be displayed

SOFTWARE/OS VERSIONS
Void Linux: 5.9.14_1
XFCE: 4.14

KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2

AppImage build #356

Files opened with:
Nemo: 4.6.5
GNOME Terminal: 3.38.0

ADDITIONAL INFORMATION
Comment 1 Waqar Ahmed 2021-06-12 15:23:07 UTC
Can not reproduce on master.

Sounds a bit weird, since I use Kate -n the whole day, and probably every 10 minutes while working on Kate. 

Do you maybe have a backtrace for this?
Comment 2 Tcll 2021-06-12 15:56:02 UTC
just checked dmesg:

[317934.260387] AppRun.wrapped[9317]: segfault at 968 ip 00007fdd88b2005a sp 0007ffe0e5e2d50 error 4 in libX11.so.6.4.0[7fdd88b0a000+8b000]
[317934.260392] Code: 8b 47 58 c3 66 66 2e 0f 1f 84 00 00 00 00 00 90 8b 47 50 c3 66 66 2e 0f 1f 84 00 00 00 00 00 90 41 54 55 48 89 fd 48 83 ec 08 <48> 8b 87 68 09 00 00 48 85 c0 74 02 ff 10 48 89 ef e8 50 26 01 00

hopefully that helps
Comment 3 Christoph Cullmann 2021-06-12 18:33:32 UTC
Hmm, unfortunately this output is not very helpful, but shows that it indeed does crash.

Could this be an issue with the packaged version on Void Linux?
Comment 4 Tcll 2021-06-12 19:36:55 UTC
I won't deny it could be a Void Linux issue, since my old Void machine runs Blender 2.8+ at 1.5FPS, where this one runs it just fine (updated)

and it seems like it specifically has to do with libX11...
which funny enough is something I'm RE-ing the protocol of for a project of my own that manages /tmp/.X11-unix/X0 directly as a bi-directional named pipe for performance and compatibility reasons.

but unfortunately, I wouldn't know how to tell you what functions or such specifically seem to be missing from my specific patch to where it could potentially be worked around as an exception...

my experience with C is rather lacking due to there not being a decent FOSS IDE for it...
(CLion is quite a big load to cover) ;)


... I could probably patch it manually, and then deal with any XBPS issues later if I can find a decent download >.>
(no internet on the target machine)
Comment 5 Tcll 2021-06-12 21:28:56 UTC
well, it's not libX11
just had a friend copy their libX11.so.6.3.0
and when I ran kate with that, the same segfault happened

so now I'm starting to think something's not installed that libX11 needs that I don't have installed...
Comment 6 Christoph Cullmann 2021-06-12 21:34:44 UTC
Can you start kate inside gdb and attach then the backtrace you get with "bt" after the crash?
Comment 7 Tcll 2021-06-12 23:52:41 UTC
Created attachment 139272 [details]
Insight-gdb moment of kate crash
Comment 8 Tcll 2021-06-12 23:53:46 UTC
well I didn't have gdb on my system, and there wasn't a release available for download (only a source package)
so I found this portable program called Insight which bundled gdb in it's release...

anyways, I did some probing and may have found a lead on something related to one of the plugins:
KF5WindowSystemX11Plugin.so

I had to extract kate from the appimage to get it to work,
but the attached image (kate_debug.png) may hopefully provide more info
the green line is the moment of the crash

`rdi+0x968` is a solid address
hopefully that relates to an existing pointer in the source
Comment 9 Christoph Cullmann 2021-06-13 06:57:29 UTC
Hmm, this all looks for me like something very deep in the stack is just broken or incompatible.

Is Kate out of an AppImage? Is that the image we provide?
Or is that the package of the distro?
Comment 10 Tcll 2021-06-13 11:54:17 UTC
yes as stated, it's the appimage, read the initial post for the build reference. ;)

no it's not the latest, but it's within the week to at least be relevant...
(I'm fairly certain this hasn't been tackled yet in the latest appimage, but I can transfer it over when my flash drive is free to test)
Comment 11 Waqar Ahmed 2021-12-07 05:52:31 UTC
Can you confirm if it still crashes with latest master?
Comment 12 Tcll 2021-12-07 16:13:26 UTC
(In reply to Waqar Ahmed from comment #11)
> Can you confirm if it still crashes with latest master?

thanks for notifying ;)

I can confirm with the latest kate-21.08.3-537 appimage
the segfault appears to have been resolved :+1:
I can now run multiple instances with behavior similar to mousepad :)

also just to note, there's another issue where the process doesn't terminate after being closed.
I no longer use kate now that I've found xed, but I'm at least glad to have confirmed the fix. ;)
Comment 13 Waqar Ahmed 2021-12-07 16:30:38 UTC
Thanks :)