Bug 444971 - Okular crashed when opening a markdown file
Summary: Okular crashed when opening a markdown file
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 21.08.2
Platform: OpenSUSE Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2021-11-04 19:04 UTC by Steven Lin
Modified: 2021-11-09 16:04 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 21.12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Lin 2021-11-04 19:04:24 UTC
Application: okular (21.08.2)

Qt Version: 5.15.2
Frameworks Version: 5.87.0
Operating System: Linux 5.14.14-1-default x86_64
Windowing System: X11
Distribution: "openSUSE Tumbleweed"
DrKonqi: 5.23.2 [KCrashBackend]

-- Information about the crash:
- What I was doing when the application crashed:
I tried opening a markdown file from dolphin, and then it crashed.
Here is the markdown file: 
https://github.com/syl20bnr/spacemacs/blob/develop/README.md

The crash can be reproduced every time.

-- Backtrace:
Application: Okular (okular), signal: Segmentation fault
Content of s_kcrashErrorMessage: std::unique_ptr<char []> = {get() = {<No data fields>}}
[KCrash Handler]
#6  0x00007f1ef020c2a3 in QFragmentMapData<QTextFragmentData>::next (this=<optimized out>, this=<optimized out>, n=7274595) at ../../include/QtGui/5.15.2/QtGui/private/../../../../../src/gui/text/qfragmentmap_p.h:295
#7  QFragmentMap<QTextFragmentData>::next (n=<optimized out>, this=<optimized out>) at ../../include/QtGui/5.15.2/QtGui/private/../../../../../src/gui/text/qfragmentmap_p.h:859
#8  QTextBlock::iterator::operator++ (this=this@entry=0x7ffc644b1150) at text/qtextobject.cpp:1615
#9  0x00007f1ee1ae1cb8 in Markdown::Converter::convertImages (this=<optimized out>, textDocument=0x55d751be8760, dir=..., parent=...) at /usr/src/debug/okular-21.08.2-1.1.x86_64/generators/markdown/converter.cpp:184
#10 Markdown::Converter::convertImages (parent=parent@entry=0x55d751c5ed10, dir=..., textDocument=textDocument@entry=0x55d751be8760, this=0x55d751bc84e0) at /usr/src/debug/okular-21.08.2-1.1.x86_64/generators/markdown/converter.cpp:177
#11 0x00007f1ee1ae2396 in Markdown::Converter::convertOpenFile (this=this@entry=0x55d751bc84e0) at /usr/src/debug/okular-21.08.2-1.1.x86_64/generators/markdown/converter.cpp:125
#12 0x00007f1ee1ae2591 in Markdown::Converter::convert (this=0x55d751bc84e0, fileName=...) at /usr/src/debug/okular-21.08.2-1.1.x86_64/generators/markdown/converter.cpp:68
#13 0x00007f1ee2448f3f in Okular::TextDocumentConverter::convertWithPassword (fileName=..., this=0x55d751bc84e0) at /usr/src/debug/okular-21.08.2-1.1.x86_64/core/textdocumentgenerator.cpp:52
#14 Okular::TextDocumentGenerator::loadDocumentWithPassword (this=<optimized out>, fileName=..., pagesVector=..., password=...) at /usr/src/debug/okular-21.08.2-1.1.x86_64/core/textdocumentgenerator.cpp:290
#15 0x00007f1ee240bc1c in Okular::DocumentPrivate::openDocumentInternal (this=0x55d7510ce260, offer=..., isstdin=<optimized out>, docFile=..., filedata=..., password=...) at /usr/src/debug/okular-21.08.2-1.1.x86_64/core/document.cpp:890
#16 0x00007f1ee24181eb in Okular::Document::openDocument (this=this@entry=0x55d7512fa100, docFile=..., url=..., _mime=..., password=...) at /usr/src/debug/okular-21.08.2-1.1.x86_64/core/document.cpp:2330
#17 0x00007f1ee2555d75 in Okular::Part::doOpenFile (this=this@entry=0x55d7512fef20, mimeA=..., fileNameToOpenA=..., isCompressedFile=isCompressedFile@entry=0x7ffc644b1917) at /usr/src/debug/okular-21.08.2-1.1.x86_64/part/part.cpp:1393
#18 0x00007f1ee255860b in Okular::Part::openFile (this=0x55d7512fef20) at /usr/src/debug/okular-21.08.2-1.1.x86_64/part/part.cpp:1511
#19 0x00007f1ef13aa265 in KParts::ReadOnlyPartPrivate::openLocalFile (this=this@entry=0x55d751307620) at /usr/src/debug/kparts-5.87.0-1.1.x86_64/src/readonlypart.cpp:180
#20 0x00007f1ef13ae937 in KParts::ReadOnlyPart::openUrl (this=this@entry=0x55d7512fef20, url=...) at /usr/src/debug/kparts-5.87.0-1.1.x86_64/src/readonlypart.cpp:141
#21 0x00007f1ee25569a3 in Okular::Part::openUrl (this=<optimized out>, _url=..., swapInsteadOfOpening=<optimized out>) at /usr/src/debug/okular-21.08.2-1.1.x86_64/part/part.cpp:1743
#22 0x000055d7503213bb in Shell::openUrl (this=<optimized out>, url=..., serializedOptions=...) at /usr/src/debug/okular-21.08.2-1.1.x86_64/shell/shell.cpp:285
#23 0x000055d7503265ee in Shell::openDocument (this=0x55d751302950, url=..., serializedOptions=...) at /usr/src/debug/okular-21.08.2-1.1.x86_64/shell/shell.cpp:236
#24 0x000055d75031da85 in Shell::openDocument (serializedOptions=..., url=..., this=0x55d751302950) at /usr/src/debug/okular-21.08.2-1.1.x86_64/shell/okular_main.cpp:158
#25 Okular::main (serializedOptions=..., paths=...) at /usr/src/debug/okular-21.08.2-1.1.x86_64/shell/okular_main.cpp:162
#26 main (argc=<optimized out>, argv=0x7ffc644b1eb0) at /usr/src/debug/okular-21.08.2-1.1.x86_64/shell/main.cpp:91
[Inferior 1 (process 11254) detached]

Possible duplicates by query: bug 443057.

Reported using DrKonqi
Comment 1 Nicolas Fella 2021-11-04 19:49:21 UTC
Can reproduce on current master
Comment 2 Bug Janitor Service 2021-11-04 23:37:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/501
Comment 3 Albert Astals Cid 2021-11-08 23:18:00 UTC
Git commit f686f4c6bf45b92784a6bf90a037199158ff0073 by Albert Astals Cid.
Committed on 08/11/2021 at 21:23.
Pushed by aacid into branch 'release/21.12'.

Markdown: Don't crash on files with html images, alt text, inside links

If we have code like <a><img></a><a><img></a> and the img has alt text

The old code did
  remove image
  insert alt text
but when we remove the image, the qtextdocument says
  "i don't need the <a> anymore since there's nothing inside"
and then everything breaks because the layout has changed and we're
iterating over "unexisting" text blocks

So instead we just insert the alt text and
since we have selected the image with the cursor it will
replace it correctly

M  +0    -1    generators/markdown/converter.cpp

https://invent.kde.org/graphics/okular/commit/f686f4c6bf45b92784a6bf90a037199158ff0073