Bug 462326 - kgraphviewer crashes when loading file
Summary: kgraphviewer crashes when loading file
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kgraphviewer
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Gaël de Chalendar (aka Kleag)
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2022-11-27 20:18 UTC by Lova
Modified: 2023-01-02 21:34 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
file that crashes kgraphview (143.52 KB, text/vnd.graphviz)
2022-11-27 20:19 UTC, Lova
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lova 2022-11-27 20:18:49 UTC
Application: kgraphviewer (2.4.3)

Qt Version: 5.15.7
Frameworks Version: 5.100.0
Operating System: Linux 6.0.9-arch1-1 x86_64
Windowing System: Wayland
Distribution: Arch Linux
DrKonqi: 5.26.3 [KCrashBackend]

-- Information about the crash:
KGraphViewer crashes immediately when loading .dot files. A file that triggers a crash with 100% certainty for me is attached. The same file works good with xdot.

The crash can be reproduced every time.

-- Backtrace:
Application: KGraphViewer (kgraphviewer), signal: Segmentation fault

[KCrash Handler]
#4  0x00007f7cdc10d863 in  () at /usr/lib/libkgraphviewer.so.3
#5  0x00007f7cdc123731 in  () at /usr/lib/libkgraphviewer.so.3
#6  0x00007f7cdc12b7e5 in KGraphViewer::DotGraphView::loadLibrary(Agraph_s*, QString const&) () at /usr/lib/libkgraphviewer.so.3
#7  0x00007f7cdc12b9cc in KGraphViewer::DotGraphView::slotAGraphLayoutFinished() () at /usr/lib/libkgraphviewer.so.3
#8  0x00007f7cfbcb0be0 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#9  0x00007f7cfca5d823 in QFrame::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#10 0x00007f7cfc978b1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#11 0x00007f7cfbc8cf98 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#12 0x00007f7cfbc8daa3 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt5Core.so.5
#13 0x00007f7cfbcd3e68 in  () at /usr/lib/libQt5Core.so.5
#14 0x00007f7cfa51687b in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#15 0x00007f7cfa56d279 in  () at /usr/lib/libglib-2.0.so.0
#16 0x00007f7cfa515132 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#17 0x00007f7cfbcd7c4c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#18 0x00007f7cfbc8573c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#19 0x00007f7cfbc90269 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#20 0x0000557212df06ec in  ()
#21 0x00007f7cfb43c290 in  () at /usr/lib/libc.so.6
#22 0x00007f7cfb43c34a in __libc_start_main () at /usr/lib/libc.so.6
#23 0x0000557212df0f9e in _start ()
[Inferior 1 (process 42339) detached]

The reporter indicates this bug may be a duplicate of or related to bug 246059.

Reported using DrKonqi
Comment 1 Lova 2022-11-27 20:19:53 UTC
Created attachment 154092 [details]
file that crashes kgraphview
Comment 2 Grzegorz Szymaszek 2022-12-28 22:26:59 UTC
I cannot reproduce the bug using the attached file on kgraphviewer 2.4.3 built from current master, commit 2347c7de3fba1789a5b7138afe4989b1e55c3062.

Distribution: Debian bookworm
Qt Version: 5.15.6
Frameworks Version: 5.101.0
Operating System: Linux (from Debian package linux-image-6.0.0-6-amd64 6.0.12-1)
Windowing System: Wayland (Sway, from Debian package sway 1.7-6)
Comment 3 Lova 2022-12-28 23:28:43 UTC
I can still reproduce it. Will try building kgraphviewer from your commit and report back.
Comment 4 Lova 2022-12-28 23:41:08 UTC
Ok, so I can confirm that the build from the commit you provided does not crash. Compiling using the source for https://download.kde.org/stable/kgraphviewer/2.4.3/kgraphviewer-2.4.3.tar.xz however, which is the version that Arch uses for its package, does crash.

Therefore, I believe it's safe to assume that this issue has been fixed at some point in master :)
Comment 5 Grzegorz Szymaszek 2022-12-29 10:27:23 UTC
I’m afraid I’m still unable to reproduce it here. I’ve tried both the linked tarball and the source from git tag v2.4.3, but neither of them wants to crash. Could you try to bisect git commits between the tag and the current master to find out which one possibly fixed the problem?
Comment 6 Lova 2022-12-29 11:32:56 UTC
Ok, the plot thickens. 

I realized that the reason why one build (your commit) worked, while the other did not, was the fact that the one I built from the tarball, I had issued "make install" for. This meant that the library and the binary got separated into bin and lib respectively, and I was running the binary from the locally installed bin directory without setting LD_LIBRARY_PATH, and thus it was picking up the globally installed libkgraphviewer.so.2.4.3.
In the case of the master build, I was simply running the binary from the bin folder in the build directory, which apparently bundles all cmake target outputs together.

So I tried setting LD_LIBRARY_PATH manually to force the built libkgraphviewer.so.2.4.3 to be used... and then both master and even the 2.4.3 tarball worked. Manually copying my built libkgraphviewer.so.2.4.3 to /usr/lib also allowed my installed kgraphviewer to work.

I figured it must be something with the way Arch builds the package, but the PKGBUILD could not be any simpler: https://raw.githubusercontent.com/archlinux/svntogit-community/packages/kgraphviewer/trunk/PKGBUILD

My next idea was the compiler flags. I checked /etc/makepkg, which sets the following global CXXFLAGS:

-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS

Compiling with these flags did not make a difference. I could still not get kgraphviewer to crash.

Finally, I downloaded the PKGBUILD and ran makepkg manually, and installed my manually built package, just in case there would be something in the makepkg process that sets any flags that I am not aware of. Guess what? It worked wonderfully, no crash at all.

So right now, it *seems* like the package on the Arch package mirrors for some reason has this crash. But compiling the source myself from the very same PKGBUILD does not yield the problem.

I imagine that this is some kind of downstream problem, so I will report it to Arch Linux instead.
Comment 7 Grzegorz Szymaszek 2022-12-29 13:26:39 UTC
I’ve checked a few build scripts of other CMake-based programs (kquickimageeditor, plasma-pass, qgis), and the build() and package() functions are written in a quite different way; but I’m not sure which one is better.

Could you try to compare the contents of the Arch package and the one you’ve built? Perhaps the build environment, ie the libraries available and their versions make the difference, perhaps you should build it in a fresh chroot that has only those dependencies the Arch-package-building-software deems necessary.
Comment 8 Lova 2023-01-02 21:34:46 UTC
I created a bug report at https://bugs.archlinux.org/task/76957 and the package has now been rebuilt, fixing the issue. I will close this :)