https://bugs.kde.org/show_bug.cgi?id=424522
Bug ID: 424522 Summary: dynamic_cast<Okular::ViewerInterface *>(activePart) is null Product: okular Version: unspecified Platform: Gentoo Packages OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: general Assignee: okular-de...@kde.org Reporter: w12101...@outlook.com Target Milestone: --- SUMMARY In shell/shell.cpp, Shell::openUrl(), `dynamic_cast<Okular::ViewerInterface *>(activePart)` is null and cause segmentation fault. STEPS TO REPRODUCE (1) 1. Launch okular 2. Open a pdf file 3. Press ctrl-o to open another pdf 4. Okular crash (2) 1. Set Okular as default pdf viewer 2. Open a pdf file in Dolphin 3. Okular crash OBSERVED RESULT backtrace: #4 Shell::openUrl (this=0x11b99a0, url=..., serializedOptions=...) at ../okular-20.04.3/shell/shell.cpp:276 #5 0x00000000002195e3 in Shell::fileOpen (this=<optimized out>) at ../okular-20.04.3/shell/shell.cpp:501 #6 0x00007f689c89c8b7 in ?? () from /usr/lib64/libQt5Core.so.5 #7 0x00007f689d2e9b4c in QAction::activate(QAction::ActionEvent) () from /usr/lib64/libQt5Widgets.so.5 #8 0x00007f689d2e9959 in QAction::event(QEvent*) () from /usr/lib64/libQt5Widgets.so.5 #9 0x00007f689d2f3260 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib64/libQt5Widgets.so.5 #10 0x00007f689d2f46b0 in QApplication::notify(QObject*, QEvent*) () from /usr/lib64/libQt5Widgets.so.5 #11 0x00007f689c869242 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib64/libQt5Core.so.5 #12 0x00007f689cc35015 in QShortcutMap::dispatchEvent(QKeyEvent*) () from /usr/lib64/libQt5Gui.so.5 #13 0x00007f689cc341f3 in QShortcutMap::tryShortcut(QKeyEvent*) () from /usr/lib64/libQt5Gui.so.5 #14 0x00007f689cbe4292 in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) () from /usr/lib64/libQt5Gui.so.5 #15 0x00007f689cc04bdd in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) () from /usr/lib64/libQt5Gui.so.5 #16 0x00007f689cbe895a in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Gui.so.5 #17 0x00007f68983db93a in ?? () from /usr/lib64/libQt5XcbQpa.so.5 #18 0x00007f6899290e39 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0 #19 0x00007f6899291563 in ?? () from /usr/lib64/libglib-2.0.so.0 #20 0x00007f689929181b in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0 #21 0x00007f689c8c1018 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5 #22 0x00007f689c865076 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5 #23 0x00007f689c869831 in QCoreApplication::exec() () from /usr/lib64/libQt5Core.so.5 #24 0x0000000000211c12 in main (argc=1, argv=<optimized out>) at ../okular-20.04.3/shell/main.cpp:113 Add a hack to this function: diff --git a/shell/shell.cpp b/shell/shell.cpp index 5d218e28d..f6c84b6d9 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -257,7 +257,11 @@ void Shell::openUrl(const QUrl &url, const QString &serializedOptions) applyOptionsToPart(activePart, serializedOptions); activePart->openUrl(url); } else { - if (dynamic_cast<Okular::ViewerInterface *>(activePart)->openNewFilesInTabs()) { + Okular::ViewerInterface * vi = dynamic_cast<Okular::ViewerInterface *>(activePart); + if ( ! vi) { + printf("vi is null, activePart: %p\n", activePart); + } + if (vi && vi ->openNewFilesInTabs()) { openNewTab(url, serializedOptions); } else { Shell *newShell = new Shell(serializedOptions); And recompile it, open some pdfs, the output is: kf5.kio.kdirmodel: protocol mismatch: "" vs "file" kf5.kio.kdirmodel: protocol mismatch: "" vs "file" vi is null, activePart: 0x1d7f840 Settings::instance called after the first use - ignoring kf5.kio.kdirmodel: protocol mismatch: "" vs "file" vi is null, activePart: 0x2118470 Settings::instance called after the first use - ignoring kf5.kio.kdirmodel: protocol mismatch: "" vs "file" vi is null, activePart: 0x23dcf60 Settings::instance called after the first use - ignoring So this dynamic_cast is failed. EXPECTED RESULT It should not crash SOFTWARE/OS VERSIONS Linux/KDE Plasma: (available in About System) KDE Plasma Version: 5.19.3 KDE Frameworks Version: 5.72.0 Qt Version: 5.15.0 ADDITIONAL INFORMATION I have try gentoo ebuild kde-apps/okular-20.04.3 and source code from git master branch. I use clang + lld + libc++ as primary toolchain: CC="clang" CXX="clang++" COMMON_FLAGS="-march=skylake -mtune=skylake -O2 -pipe -g" CFLAGS="${COMMON_FLAGS}" CXXFLAGS="${COMMON_FLAGS} -stdlib=libc++" LDFLAGS="-fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind" I think this bug only happend with libcxx and libcxxabi -- You are receiving this mail because: You are watching all bug changes.