Summary: | dynamic_cast<Okular::ViewerInterface *>(activePart) is null | ||
---|---|---|---|
Product: | [Applications] okular | Reporter: | 12101111 <w12101111> |
Component: | general | Assignee: | Okular developers <okular-devel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | aacid |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
12101111
2020-07-22 03:18:01 UTC
The bracktrace of (2) is different with (1): * thread #1, name = 'okular', stop reason = signal SIGSEGV: invalid address (fault address: 0x0) frame #0: 0x000000000021737d okular`Shell::openDocument(this=0x000000000031ff40, url=0x00007fffffffb3a0, serializedOptions=0x00007fffffffb468) at shell.cpp:226:57 223 KParts::ReadWritePart* const part = m_tabs[0].part; 224 225 // Return false if we can't open new tabs and the only part is occupied -> 226 if ( !dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs() 227 && !part->url().isEmpty() 228 && !ShellUtils::unique(serializedOptions)) 229 { (lldb) bt * thread #1, name = 'okular', stop reason = signal SIGSEGV: invalid address (fault address: 0x0) * frame #0: 0x000000000021737d okular`Shell::openDocument(this=0x000000000031ff40, url=0x00007fffffffb3a0, serializedOptions=0x00007fffffffb468) at shell.cpp:226:57 frame #1: 0x0000000000213ef3 okular`Okular::main(paths=<unavailable>, serializedOptions=0x00007fffffffb468) at okular_main.cpp:181:21 frame #2: 0x00000000002119f7 okular`main(argc=2, argv=<unavailable>) at main.cpp:100:33 frame #3: 0x00007ffff5d2fcaa libc.so.6`__libc_start_main + 234 frame #4: 0x000000000020fc4a okular`_start + 42 This backtrace doesn't really make any sense. Are you sure you aren't mixing system okular with self compiled okular? These two backtraces are from Gentoo's okular, and the patch mentioned is for master branch, so the line numbers of `shell.cpp` are not the same. so you are mixing up 20.04.3 and master? as said, don't do that, that's not going to work I didn't mix up them. Gentoo Linux don't provide git master version in main tree I installed kde-apps/okular-20.04.3 as normal, and it crash, so I rebuilt it using CXXFLAGS+="-g" FEATURES="nostrip installsources splitdebug" and got those backtrace. Then I download source code, edit `shell.cpp`, built (mkdir build && cd build && cmake .. -G Ninja && ninja) and run it (~/okular/build/bin/okular),then got some output. If running in build directory is not goning to work, I apply the same hack on Gentoo's package, and got the same output: kf5.kio.kdirmodel: protocol mismatch: "" vs "file" dynamic_cast<Okular::ViewerInterface *>(activePart) is null,activePart is 0x17a4170 Settings::instance called after the first use - ignoring The patch file is: /etc/portage/patches/kde-apps/okular/dynamic_cast_return_null.patch: diff --git a/shell/shell.cpp b/shell/shell.cpp index 0bdb710..d18c2d0 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -223,7 +223,9 @@ bool Shell::openDocument( const QUrl& url, const QString &serializedOptions ) KParts::ReadWritePart* const part = m_tabs[0].part; // Return false if we can't open new tabs and the only part is occupied - if ( !dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs() + Okular::ViewerInterface * vi = dynamic_cast<Okular::ViewerInterface *>(part); + if (!vi) printf("dynamic_cast<Okular::ViewerInterface *>(part) is null,part is %p\n",part); + if ( vi && !vi->openNewFilesInTabs() && !part->url().isEmpty() && !ShellUtils::unique(serializedOptions)) { @@ -246,7 +248,9 @@ bool Shell::canOpenDocs( int numDocs, int desktop ) return false; KParts::ReadWritePart* const part = m_tabs[0].part; - const bool allowTabs = dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs(); + Okular::ViewerInterface * vi = dynamic_cast<Okular::ViewerInterface *>(part); + if (!vi) printf("dynamic_cast<Okular::ViewerInterface *>(part) is null,part is %p\n",part); + const bool allowTabs = vi && vi ->openNewFilesInTabs(); if( !allowTabs && (numDocs > 1 || !part->url().isEmpty()) ) return false; @@ -273,7 +277,9 @@ void Shell::openUrl( const QUrl & url, const QString &serializedOptions ) } else { - if( dynamic_cast<Okular::ViewerInterface *>(activePart)->openNewFilesInTabs() ) + Okular::ViewerInterface * vi = dynamic_cast<Okular::ViewerInterface *>(activePart); + if (!vi) printf("dynamic_cast<Okular::ViewerInterface *>(activePart) is null,activePart is %p\n",activePart); + if( vi && vi ->openNewFilesInTabs() ) { openNewTab( url, serializedOptions ); } If Gentoo gives you release/20.04 source code, you will have 20.04 installed. Then you “download source code”, that will probably give you master source code. If you build that, and don’t `ninja install` it, your master Shell will create 20.04 Parts. Part is located in some/plugin/path/okularpart.so, not in bin/okular. But since you reproduce the problem with Gentoo package source code, that’s probably not the problem... Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone! This issue is still valid Already fixed in 49c680fd0ea7e98ddc77d455737908ed9b16bd3c |