Bug 426658 - Okular crashed while annotating document
Summary: Okular crashed while annotating document
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 1.11.1
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2020-09-17 22:24 UTC by info
Modified: 2020-11-02 19:36 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
New crash information added by DrKonqi (4.54 KB, text/plain)
2020-09-17 22:26 UTC, info
Details
New crash information added by DrKonqi (4.82 KB, text/plain)
2020-09-19 15:38 UTC, info
Details
Places to mark in the example document (131.91 KB, application/pdf)
2020-10-05 18:41 UTC, info
Details

Note You need to log in before you can comment on or make changes to this bug.
Description info 2020-09-17 22:24:40 UTC
Application: okular (1.11.1)

Qt Version: 5.15.0
Frameworks Version: 5.73.0
Operating System: Linux 5.8.7-1-default x86_64
Windowing system: X11
Distribution: "openSUSE Tumbleweed"

-- Information about the crash:
- What I was doing when the application crashed:
I was annotating a document when Okular suddenly crashed.
I am mostly using the highlighter tool to mark parts in the text. Directly after having used the mouse to select a part in the text, I double click on it to open the comment window for this new highlight.
Though since the new version, this got so slow (up to 1 second for the highlight to appear after releasing the mouse), that I often add a second highlight below where I double clicked, before the first highlight is even shown.
Like this, I have multiple times ended up in a state where the highlighter tool is still active, but I am unable to click-drag an actual highlight. Just nothing happens.
I was in this state when it crashed, so that might be related (and sounds like a race-condition to me).
I am basically saving the document (ctrl + s) after each annotation - if that changes anything.

-- Backtrace:
Application: Okular (okular), signal: Segmentation fault

[KCrash Handler]
#4  0x00007f68a4c5bee3 in Okular::Page::rotation (this=0x560983040043) at /usr/src/debug/okular-20.08.1-1.1.x86_64/core/page.cpp:173
#5  0x00007f68a4e24d28 in PageView::textSelectionForItem (this=0x560982986410, item=0x560983042620, startPoint=..., endPoint=...) at /usr/src/debug/okular-20.08.1-1.1.x86_64/ui/pageviewutils.cpp:50
#6  0x00007f68a4e08050 in TextSelectorEngine::event (this=0x56098326cdc0, type=<optimized out>, button=<optimized out>, nX=<optimized out>, nY=<optimized out>, xScale=<optimized out>, yScale=<optimized out>) at /usr/src/debug/okular-20.08.1-1.1.x86_64/ui/annotationtools.h:75
#7  0x00007f68a4e0f8f4 in PageViewAnnotator::performRouteMouseOrTabletEvent (this=0x5609827a4ce0, eventType=AnnotatorEngine::Move, button=AnnotatorEngine::Left, modifiers=..., pos=..., item=<optimized out>) at /usr/include/qt5/QtCore/qrect.h:269
#8  0x00007f68ac8fc0de in QWidget::event (this=this@entry=0x560982986410, event=event@entry=0x7ffd6f05c6c0) at kernel/qwidget.cpp:9027
#9  0x00007f68ac9a44de in QFrame::event (this=0x560982986410, e=0x7ffd6f05c6c0) at widgets/qframe.cpp:550
#10 0x00007f68abcdc9a3 in QCoreApplicationPrivate::sendThroughObjectEventFilters (event=<optimized out>, receiver=<optimized out>) at kernel/qcoreapplication.cpp:1187
#11 QCoreApplicationPrivate::sendThroughObjectEventFilters (receiver=receiver@entry=0x5609829866e0, event=event@entry=0x7ffd6f05c6c0) at kernel/qcoreapplication.cpp:1176
#12 0x00007f68ac8bc0be in QApplicationPrivate::notify_helper (this=this@entry=0x5609824f2e80, receiver=receiver@entry=0x5609829866e0, e=e@entry=0x7ffd6f05c6c0) at kernel/qapplication.cpp:3665
#13 0x00007f68ac8c3121 in QApplication::notify (this=0x7ffd6f05c3c0, receiver=0x5609829866e0, e=0x7ffd6f05c6c0) at kernel/qapplication.cpp:3115
#14 0x00007f68abcdcc3a in QCoreApplication::notifyInternal2 (receiver=0x5609829866e0, event=0x7ffd6f05c6c0) at ../../include/QtCore/5.15.0/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:325
#15 0x00007f68ac8c2036 in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x5609829866e0, event=event@entry=0x7ffd6f05c6c0, alienWidget=alienWidget@entry=0x5609829866e0, nativeWidget=0x56098268ecb0, buttonDown=buttonDown@entry=0x7f68acde19d0 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2603
#16 0x00007f68ac91413a in QWidgetWindow::handleMouseEvent (this=0x56098290a3f0, event=0x7ffd6f05c980) at /usr/include/c++/10/bits/atomic_base.h:420
#17 0x00007f68ac91762e in QWidgetWindow::event (this=0x56098290a3f0, event=0x7ffd6f05c980) at kernel/qwidgetwindow.cpp:295
#18 0x00007f68ac8bc0cf in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x56098290a3f0, e=0x7ffd6f05c980) at kernel/qapplication.cpp:3671
#19 0x00007f68abcdcc3a in QCoreApplication::notifyInternal2 (receiver=0x56098290a3f0, event=0x7ffd6f05c980) at ../../include/QtCore/5.15.0/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:325
#20 0x00007f68ac1a527b in QGuiApplicationPrivate::processMouseEvent (e=0x7f683e1c40b0) at kernel/qguiapplication.cpp:2214
#21 0x00007f68ac17b51b in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1175
#22 0x00007f68a7bc8f4a in xcbSourceDispatch (source=<optimized out>) at qxcbeventdispatcher.cpp:105
#23 0x00007f68aa3fc2b7 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#24 0x00007f68aa3fc638 in ?? () from /usr/lib64/libglib-2.0.so.0
#25 0x00007f68aa3fc6ef in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#26 0x00007f68abd3407f in QEventDispatcherGlib::processEvents (this=0x560982630430, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#27 0x00007f68abcdb5fb in QEventLoop::exec (this=this@entry=0x7ffd6f05ccb0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:141
#28 0x00007f68abce3860 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#29 0x0000560980daa896 in main (argc=<optimized out>, argv=0x7ffd6f05ce40) at /usr/src/debug/okular-20.08.1-1.1.x86_64/shell/main.cpp:109
[Inferior 1 (process 8169) detached]

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

Possible duplicates by query: bug 324747, bug 323669, bug 192293.

Reported using DrKonqi
Comment 1 info 2020-09-17 22:26:47 UTC
Created attachment 131734 [details]
New crash information added by DrKonqi

okular (1.11.1) using Qt 5.15.0

Happend again. Stack-trace for this time is attached.

-- Backtrace (Reduced):
#4  Okular::Page::rotation (this=0x561700000000) at /usr/src/debug/okular-20.08.1-1.1.x86_64/core/page.cpp:173
#5  0x00007fc59354fd28 in PageView::textSelectionForItem (this=0x561700bfe520, item=0x56170166fab0, startPoint=..., endPoint=...) at /usr/src/debug/okular-20.08.1-1.1.x86_64/ui/pageviewutils.cpp:50
#6  0x00007fc593533050 in TextSelectorEngine::event (this=0x5617015495e0, type=<optimized out>, button=<optimized out>, nX=<optimized out>, nY=<optimized out>, xScale=<optimized out>, yScale=<optimized out>) at /usr/src/debug/okular-20.08.1-1.1.x86_64/ui/annotationtools.h:75
#7  0x00007fc59353a8f4 in PageViewAnnotator::performRouteMouseOrTabletEvent (this=0x561700a0ec50, eventType=AnnotatorEngine::Move, button=AnnotatorEngine::Left, modifiers=..., pos=..., item=<optimized out>) at /usr/include/qt5/QtCore/qrect.h:269
#8  0x00007fc59f0b60de in QWidget::event (this=this@entry=0x561700bfe520, event=event@entry=0x7fff8a71f930) at kernel/qwidget.cpp:9027
Comment 2 info 2020-09-17 23:08:26 UTC
I have found an anomaly.
As far as I can see up till now, the highlighter tool only stops working after having switched to the next page. So, with the behavior that might be linked to the crash, I can not annotate the next page until I deactivate and activate the highlighter tool again.

Though note, that this does not always occur! While trying to reproduce it, switching pages worked.
Comment 3 info 2020-09-19 15:38:39 UTC
Created attachment 131779 [details]
New crash information added by DrKonqi

okular (1.11.1) using Qt 5.15.0

Another crash stack for the same situation.

-- Backtrace (Reduced):
#4  QListData::isEmpty (this=<error reading variable: Cannot access memory at address 0xffffd7e8fd894855>) at /usr/include/qt5/QtCore/qlist.h:201
#5  QList<TinyTextEntity*>::isEmpty (this=<error reading variable: Cannot access memory at address 0xffffd7e8fd894855>) at /usr/include/qt5/QtCore/qlist.h:201
#6  Okular::TextPage::textArea (this=0xffffd7e8fd894855, sel=0x7ffeca49e540) at /usr/src/debug/okular-20.08.1-1.1.x86_64/core/textpage.cpp:327
#7  0x00007fc2c845bdcd in PageView::textSelectionForItem (this=<optimized out>, item=0x5632478c72f0, startPoint=..., endPoint=...) at /usr/src/debug/okular-20.08.1-1.1.x86_64/ui/pageview.cpp:3623
#8  0x00007fc2c843f050 in TextSelectorEngine::event (this=0x563247601530, type=<optimized out>, button=<optimized out>, nX=<optimized out>, nY=<optimized out>, xScale=<optimized out>, yScale=<optimized out>) at /usr/src/debug/okular-20.08.1-1.1.x86_64/ui/annotationtools.h:75
Comment 4 Simone Gaiarin 2020-09-29 07:06:49 UTC
Can you provide a precise list of steps to reproduce this? Is 'continuous mode' for annotation active when you use the highlighter?

From what I understand the steps are more or less these:
1. Continuous mode is active?
2. Click on highlighter action on the toolbar
3. Highlight some text
4. Scroll to next page (how? mouse or keyboard?)
5. Highlight some text
6. Crash happens

Can you also attach a pdf where the crash happens (or does it happen in any pdf?)
Comment 5 Albert Astals Cid 2020-09-30 22:21:39 UTC
Please answer Simone's questions
Comment 6 info 2020-10-05 18:39:51 UTC
> Can you provide a precise list of steps to reproduce this?
Not for the crash, because that simply happens after doing what I will describe below for a couple of minutes. (hint: I noticed that the crash happens more often on less potent hardware)

However, I can now reliably reproduce the condition in that the 'continuous mode' fails.
First, download https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2631779/pdf/11384513.pdf and save it in /tmp/
(See attachment "11384513_ptm.pdf" for the exact places to mark)
- Open the file in Okular.
- Click "Highlighter" tool in ToolBar of Okular, to activate it
- Scroll down
- Mark "outbreak" in the paragraphs on the right
- Doubleclick the new annotation, do not move the mouse now, directly type "asdf"
- Hit escape
- Scroll a bit up
- Mark "information" on the right
- Doubleclick the new annotation, do not move the mouse now, directly type "asdf"
- Hit escape
- Mark " parts of " on the right
- Doubleclick the new annotation, do not move the mouse now, directly type "asdf"
- Hit escape
- Mark "Cen" on the right
- Doubleclick the new annotation, do not move the mouse now, directly type "asdf"
- Hit escape
- Hit Ctrl + S
- Scroll down until you see ~10% of the next page
- Mark "The objectives of FoodNet were to accurately estimate the burden of foodborne disease in the United States, investigate the sources of infection in outbreaks and sporadic cases, and build public health infrastructure for dealing" on the right side.
- Doubleclick the new annotation, do not move the mouse now, directly type "asdf"
- Hit escape
- Hit Ctrl + S
- Scroll down
- Try to mark first word on the next page (383) -> doesn't work

Maybe that can provide you with a hint on what could cause the crash.
Comment 7 info 2020-10-05 18:41:20 UTC
Created attachment 132135 [details]
Places to mark in the example document

(I just randomly selected this document, this was not the document I was having the crashes with). I did not yet have the time to try to get Okular to crash with it.
Comment 8 Albert Astals Cid 2020-10-05 22:28:43 UTC
ok, someone needs to try to reproduce.

Maybe if you have time try running 
valgrind okular
(be patient it will be slow) and see if you can make it crash, if so please attach the log here.
Comment 9 Simone Gaiarin 2020-10-07 06:03:33 UTC
I confirm the problem regarding not being able to highlight text, but not the crash. I have repeated all the steps as described.

The problem appears also with this simplified list of steps:
1. Select a text tool annotation (e.g highlighter)
2. Select text on page 1
3. Double click the annotation
4a. Highlight text on page 2

Result:
No text selected

4b. Highlight text on page 1 again
5b. Highlight text on page 2

Result:
Text is correctly selected

Possibly this and the crash are two separates bugs.
Comment 10 Tobias Deiminger 2020-10-07 21:16:33 UTC
(In reply to Simone Gaiarin from comment #9)
> Possibly this and the crash are two separates bugs.

Imo there's a good chance that https://invent.kde.org/graphics/okular/-/merge_requests/291 fixes both "text no longer selected" and "crash".

Currently TextSelectorEngine holds a raw pointer to a PageViewItem owned by PageViewPrivate much longer than intended. Some unrelated PageView interaction can delete that PageViewItem in the meantime, leaving TextSelectorEngine::m_lockedItem dangling and causing crash on next access to m_lockedItem in TextSelectorEngine::event.

The attached crash dump is in line with that guess, so it may be worth trying MR 291.
Comment 11 Tobias Deiminger 2020-10-11 13:49:12 UTC
Closing manually because bugzilla notifier did not trigger when MR 291 was merged. You can test by compiling git master, or wait for next release 20.08.3 which is currently scheduled for November 5, 2020.
Comment 12 Christoph Feck 2020-11-02 19:36:26 UTC
> bugzilla notifier did not trigger when MR 291 was merged

Because there is no bug number 446658 :)