Bug 443057 - Okular crashes on markdown files with an image without alt text
Summary: Okular crashes on markdown files with an image without alt text
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: markdown backend (show other bugs)
Version: 21.08.1
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-28 06:39 UTC by nl6720
Modified: 2021-10-04 18:27 UTC (History)
4 users (show)

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


Attachments
test (80 bytes, text/plain)
2021-09-28 06:39 UTC, nl6720
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nl6720 2021-09-28 06:39:10 UTC
Created attachment 141978 [details]
test

SUMMARY
Okular crashes when opening a markdown file that contains an embedded image without alt text.
This happens using when the file contains something like:
![](/path/to/img.jpg)

But not with:
![Alt text](/path/to/img.jpg)

Though, the image is not displayed anyway, only the alt text.

STEPS TO REPRODUCE
1. create a test.md file containing:

![](https://kde.org/stuff/clipart/logo/kde-logo-white-blue-rounded-128x128.png)

2. Open the file in okular

OBSERVED RESULT

Okular doesn't open.
Journal shows:
Process 12264 (okular) of user 1000 dumped core.

EXPECTED RESULT
Okular opens and shows the file.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

Try opening the attached test file.
Comment 1 Paul Worrall 2021-09-28 09:08:11 UTC
When I tried to open the test file in okular, it didn't core dump, but it didn't render the file and the journal received the following message many times per second:

okular[8912]: QTextCursor::setPosition: Position '1' out of range
Comment 2 Luigi Toscano 2021-09-28 09:16:02 UTC
It would be useful to have the stack trace from the crash, but then ArchLinux doesn't make it easy as far as I know.

I can reproduce it on Okular 21.08.1, libmarkdown2 2.2.7, and I get the following backtrace:

[KCrash Handler]
#4  0x00007f1a84531b93 in QTextBlock::iterator::operator++() () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#5  0x00007f1a750823a3 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/okular/generators/okularGenerator_md.so
#6  0x00007f1a750828a5 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/okular/generators/okularGenerator_md.so
#7  0x00007f1a75082a08 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/okular/generators/okularGenerator_md.so
#8  0x00007f1a75082c01 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/okular/generators/okularGenerator_md.so
#9  0x00007f1a7c43ccab in Okular::TextDocumentGenerator::loadDocumentWithPassword(QString const&, QVector<Okular::Page*>&, QString const&) () from /usr/lib/x86_64-linux-gnu/libOkular5Core.so.9
#10 0x00007f1a7c41c4ae in ?? () from /usr/lib/x86_64-linux-gnu/libOkular5Core.so.9
#11 0x00007f1a7c41cb91 in Okular::Document::openDocument(QString const&, QUrl const&, QMimeType const&, QString const&) () from /usr/lib/x86_64-linux-gnu/libOkular5Core.so.9
#12 0x00007f1a7c5aa535 in Okular::Part::doOpenFile(QMimeType const&, QString const&, bool*) () from /usr/lib/x86_64-linux-gnu/qt5/plugins/okularpart.so
#13 0x00007f1a7c5ab2bb in Okular::Part::openFile() () from /usr/lib/x86_64-linux-gnu/qt5/plugins/okularpart.so
#14 0x00007f1a856ba505 in ?? () from /usr/lib/x86_64-linux-gnu/libKF5Parts.so.5
#15 0x00007f1a856bb5de in KParts::ReadOnlyPart::openUrl(QUrl const&) () from /usr/lib/x86_64-linux-gnu/libKF5Parts.so.5
#16 0x00007f1a7c59bbf3 in Okular::Part::openUrl(QUrl const&, bool) () from /usr/lib/x86_64-linux-gnu/qt5/plugins/okularpart.so
[...]



Which version of libmarkdown do you both have?
Comment 3 Paul Worrall 2021-09-28 09:33:05 UTC
libmarkdown2 version 2.2.6-1 from ubuntu focal repository

Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-36-generic (64-bit)
Graphics Platform: X11
Processors: 2 × AMD A6-6400K APU with Radeon(tm) HD Graphics
Memory: 7.7 GiB of RAM
Graphics Processor: AMD CEDAR
Comment 4 nl6720 2021-09-28 14:11:14 UTC
/usr/lib/libmarkdown.so is owned by discount 2.2.7-1
Comment 5 Bug Janitor Service 2021-09-28 16:25:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/490
Comment 6 Bug Janitor Service 2021-09-28 21:20:40 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/491
Comment 7 Albert Astals Cid 2021-09-29 10:07:38 UTC
Git commit 3b8cbc33204be4a88df56150078d42149b0dc6cf by Albert Astals Cid.
Committed on 29/09/2021 at 07:47.
Pushed by aacid into branch 'master'.

markdown: Only remove text if we're going to add something

Otherwise things get confused

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

https://invent.kde.org/graphics/okular/commit/3b8cbc33204be4a88df56150078d42149b0dc6cf
Comment 8 Albert Astals Cid 2021-09-29 16:23:53 UTC
Git commit bbc775909cb0e224d0a1ef38663add2bf9c91721 by Albert Astals Cid.
Committed on 29/09/2021 at 16:23.
Pushed by aacid into branch 'release/21.08'.

markdown: Only remove text if we're going to add something

Otherwise things get confused
(cherry picked from commit 3b8cbc33204be4a88df56150078d42149b0dc6cf)

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

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