Bug 361746 - Crashes on opening corrupted jpg file
Summary: Crashes on opening corrupted jpg file
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (other bugs)
Version First Reported In: 2.9.11
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2016-04-14 02:07 UTC by Elric T
Modified: 2023-01-18 03:55 UTC (History)
1 user (show)

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


Attachments
the jpeg (1018.12 KB, image/jpeg)
2016-04-14 07:15 UTC, Elric T
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Elric T 2016-04-14 02:07:20 UTC
Application: krita (2.9.11)
KDE Platform Version: 4.14.18
Qt Version: 4.8.7
Operating System: Linux 4.5.0-2-MANJARO x86_64
Distribution: "Manjaro Linux"

-- Information about the crash:
- What I was doing when the application crashed:
I opened a jpeg file. The jpeg file is corrupt.
There is another post but the backtrace looks diffrent.

The crash can be reproduced every time.

-- Backtrace:
Application: Krita (krita), signal: Aborted
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f55ad611840 (LWP 19052))]

Thread 3 (Thread 0x7f5589496700 (LWP 19065)):
#0  0x00007f55a59ba03f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f55ab33a696 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQtCore.so.4
#2  0x00007f55ac3c76dc in ?? () from /usr/lib/libQtGui.so.4
#3  0x00007f55ab33a12c in ?? () from /usr/lib/libQtCore.so.4
#4  0x00007f55a59b4424 in start_thread () from /usr/lib/libpthread.so.0
#5  0x00007f55aaa5ccbd in clone () from /usr/lib/libc.so.6

Thread 2 (Thread 0x7f557f24a700 (LWP 19066)):
#0  0x00007ffd96f6e969 in ?? ()
#1  0x00007ffd96f6ec65 in clock_gettime ()
#2  0x00007f55aaa69946 in clock_gettime () from /usr/lib/libc.so.6
#3  0x00007f55ab394b15 in ?? () from /usr/lib/libQtCore.so.4
#4  0x00007f55ab47b6c5 in ?? () from /usr/lib/libQtCore.so.4
#5  0x00007f55ab479f2c in ?? () from /usr/lib/libQtCore.so.4
#6  0x00007f55ab479ff5 in ?? () from /usr/lib/libQtCore.so.4
#7  0x00007f55a53e350d in g_main_context_prepare () from /usr/lib/libglib-2.0.so.0
#8  0x00007f55a53e3eab in ?? () from /usr/lib/libglib-2.0.so.0
#9  0x00007f55a53e408c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#10 0x00007f55ab47a85e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#11 0x00007f55ab448d51 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#12 0x00007f55ab4490c5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#13 0x00007f55ab337839 in QThread::exec() () from /usr/lib/libQtCore.so.4
#14 0x00007f55ab428ea3 in ?? () from /usr/lib/libQtCore.so.4
#15 0x00007f55ab33a12c in ?? () from /usr/lib/libQtCore.so.4
#16 0x00007f55a59b4424 in start_thread () from /usr/lib/libpthread.so.0
#17 0x00007f55aaa5ccbd in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7f55ad611840 (LWP 19052)):
[KCrash Handler]
#6  0x00007f55aa9a82a8 in raise () from /usr/lib/libc.so.6
#7  0x00007f55aa9a972a in abort () from /usr/lib/libc.so.6
#8  0x00007f55ab32f4fd in qt_message_output(QtMsgType, char const*) () from /usr/lib/libQtCore.so.4
#9  0x00007f55ab32f681 in ?? () from /usr/lib/libQtCore.so.4
#10 0x00007f55ab32ffa1 in qFatal(char const*, ...) () from /usr/lib/libQtCore.so.4
#11 0x00007f55acffbb87 in KisPart::instance() () from /usr/lib/libkritaui.so.14
#12 0x00007f55acfdc21b in KisMainWindow::~KisMainWindow() () from /usr/lib/libkritaui.so.14
#13 0x00007f55acfdc559 in KisMainWindow::~KisMainWindow() () from /usr/lib/libkritaui.so.14
#14 0x00007f55acffb8d9 in KisPart::~KisPart() () from /usr/lib/libkritaui.so.14
#15 0x00007f55acffba99 in KisPart::~KisPart() () from /usr/lib/libkritaui.so.14
#16 0x00007f55aa9aac38 in __run_exit_handlers () from /usr/lib/libc.so.6
#17 0x00007f55aa9aac85 in exit () from /usr/lib/libc.so.6
#18 0x00007f5593481b6c in ?? () from /usr/lib/libjpeg.so.8
#19 0x00007f5593472173 in jpeg_read_header () from /usr/lib/libjpeg.so.8
#20 0x00007f55629175b7 in ?? () from /usr/lib/kde4/kritajpegimport.so
#21 0x00007f5562914b7b in ?? () from /usr/lib/kde4/kritajpegimport.so
#22 0x00007f55acfc9b16 in ?? () from /usr/lib/libkritaui.so.14
#23 0x00007f55acfc8858 in KisFilterChain::invokeChain() () from /usr/lib/libkritaui.so.14
#24 0x00007f55acfd6170 in KisImportExportManager::importDocument(QString const&, QString const&, KisImportExportFilter::ConversionStatus&) () from /usr/lib/libkritaui.so.14
#25 0x00007f55acfb289e in KisDocument::openFile() () from /usr/lib/libkritaui.so.14
#26 0x00007f55acfb97d1 in ?? () from /usr/lib/libkritaui.so.14
#27 0x00007f55acfb612f in KisDocument::openUrlInternal(KUrl const&) () from /usr/lib/libkritaui.so.14
#28 0x00007f55acfb63b5 in KisDocument::openUrl(KUrl const&, KisDocument::OpenUrlFlags) () from /usr/lib/libkritaui.so.14
#29 0x00007f55acfdfe62 in KisMainWindow::openDocumentInternal(KUrl const&, KisDocument*) () from /usr/lib/libkritaui.so.14
#30 0x00007f55acf9d4b5 in KisApplication::start() () from /usr/lib/libkritaui.so.14
#31 0x000000000040287d in ?? ()
#32 0x00007f55aa995710 in __libc_start_main () from /usr/lib/libc.so.6
#33 0x00000000004034b9 in _start ()

Possible duplicates by query: bug 360929, bug 355607.

Reported using DrKonqi
Comment 1 Halla Rempt 2016-04-14 05:33:09 UTC
Hi,

Can you attach the jpeg file? The crash happens inside the jpeg library: which one exactly is installed on manjaro?
Comment 2 Elric T 2016-04-14 07:15:19 UTC
Created attachment 98395 [details]
the jpeg

Since manjaro is bleeding edge i would think a rather new one :D.
Let me ask in the irc will update then.
Comment 3 Elric T 2016-04-14 07:17:26 UTC
pacman -Si openjpeg
Repository      : extra
Name            : openjpeg
Version         : 1.5.2-1
Description     : An open source JPEG 2000 codec
Architecture    : x86_64
URL             : http://www.openjpeg.org
Licenses        : BSD
Groups          : None
Provides        : None
Depends On      : zlib
Optional Deps   : lcms2: j2k_to_image and image_to_j2k programs
                  libpng: j2k_to_image and image_to_j2k programs
Conflicts With  : None
Replaces        : None
Download Size   : 134.84 KiB
Installed Size  : 419.00 KiB
Packager        : Jan de Groot <jgc@archlinux.org>
Build Date      : Mon 28 Apr 2014 09:43:52 AM CEST
Validated By    : MD5 Sum  SHA-256 Sum  Signature
Comment 4 Halla Rempt 2016-04-14 07:34:55 UTC
Ah, that's openjpeg, which is, confusingly, not a jpeg library, but a library for loading jp2 images.
Comment 5 Elric T 2016-04-14 08:33:02 UTC
O sry.
Now i think if got them(hopefully :D):

pacman -Si libjpeg-turbo
Repository      : extra
Name            : libjpeg-turbo
Version         : 1.4.2-2
Description     : JPEG image codec with accelerated baseline compression and
                  decompression
Architecture    : x86_64
URL             : http://libjpeg-turbo.virtualgl.org/
Licenses        : custom
Groups          : None
Provides        : libjpeg=8.0.2  turbojpeg
Depends On      : None
Optional Deps   : None
Conflicts With  : libjpeg  turbojpeg
Replaces        : libjpeg  turbojpeg
Download Size   : 346.95 KiB
Installed Size  : 1454.00 KiB
Packager        : Gaetan Bisson <bisson@archlinux.org>
Build Date      : Sat 05 Dec 2015 10:50:55 PM CET
Validated By    : MD5 Sum  SHA-256 Sum  Signature

Or Maybe its:

pacman -Si lib32-libjpeg-turbo
Repository      : multilib
Name            : lib32-libjpeg-turbo
Version         : 1.4.2-1
Description     : libjpeg derivative with accelerated baseline JPEG compression
                  and decompression (32-bit)
Architecture    : x86_64
URL             : http://libjpeg-turbo.virtualgl.org/
Licenses        : custom
Groups          : None
Provides        : lib32-libjpeg=8.0.2  lib32-turbojpeg
Depends On      : lib32-glibc  libjpeg-turbo
Optional Deps   : None
Conflicts With  : lib32-libjpeg  lib32-turbojpeg
Replaces        : lib32-libjpeg  lib32-turbojpeg
Download Size   : 120.61 KiB
Installed Size  : 644.00 KiB
Packager        : Felix Yan <felixonmars@archlinux.org>
Build Date      : Thu 08 Oct 2015 03:47:31 PM CEST
Validated By    : MD5 Sum  SHA-256 Sum  Signature


Greetings.
If it isnt one of those, then iv got to have a talk with the guys in the IRC again :D.
Comment 6 Halla Rempt 2016-04-14 09:12:50 UTC
Yes, that's the right one :-)
Comment 7 Halla Rempt 2016-04-14 11:19:07 UTC
Hm, the trick is going to be to teach libjpeg to not crash on a broken file...
Comment 8 Elric T 2016-04-14 11:28:16 UTC
That sounds like a plan :D. Is there any way to recover this file? Will there be an "upstream" (is that the right name?), bugfix? I think its strange that the developer, never thought. "Hey maybe i should catch broken file exceptions".
Comment 9 Halla Rempt 2016-04-14 11:51:55 UTC
Git commit 5c4c327ad429def4eaccc8d7bbd8f70d374a51ae by Boudewijn Rempt.
Committed on 14/04/2016 at 11:51.
Pushed by rempt into branch 'master'.

M  +273  -255  plugins/impex/jpeg/kis_jpeg_converter.cc

http://commits.kde.org/krita/5c4c327ad429def4eaccc8d7bbd8f70d374a51ae
Comment 10 Halla Rempt 2016-04-14 11:55:35 UTC
To recover the file, you need specialized tools, I'm afraid.  The jpeg library says:

Corrupt JPEG data: 5 extraneous bytes before marker 0xd5
JPEG datastream contains no image

So the image is well and truly hosed. But I just added an error handler, and yes, it's weird we never did that before! This plugin is eleven years old...
Comment 11 Elric T 2016-04-14 12:02:27 UTC
Thank you very much :).
Comment 12 amyspark 2023-01-18 03:55:48 UTC
Git commit 9b7b48f4da5655035497be17e516b4a826f8b54e by L. E. Segovia.
Committed on 18/01/2023 at 02:42.
Pushed by lsegovia into branch 'master'.

global: Fix ECM exception handling semantics mismatch in MSVC

According to the Extra CMake Modules documentation [1],

> kde_enable_exceptions()
>
> Enables exceptions for C++ source files compiled for the CMakeLists.txt
> file in the current directory and all subdirectories.

What isn't listed there, however, is that exceptions are enabled through
the usage of -fexceptions (GCC/Clang) and -EHsc (MSVC/Intel) [2]. All
good... except that those mean slightly different things:

> -fexceptions
>
>    Enable exception handling. Generates extra code needed to propagate
>    exceptions. For some targets, this implies GCC generates frame
>    unwind information for all functions, which can produce significant
>    data size overhead, although it does not affect execution. If you do
>    not specify this option, GCC enables it by default for languages
>    like C++ that normally require exception handling, and disables it
>    for languages like C that do not normally require it. However, you
>    may need to enable this option when compiling C code that needs to
>    interoperate properly with exception handlers written in C++. You
>    may also wish to disable this option if you are compiling older C++
>    programs that don’t use exception handling.

(source: [3])

> c
> When used with /EHs, the compiler assumes that functions declared as
> extern "C" never throw a C++ exception. It has no effect when used with
> /EHa (that is, /EHca is equivalent to /EHa). /EHc is ignored if /EHs or
> /EHa aren't specified.

(source: [4])

These two put together mean that any exception thrown in a callstack
with C code in between works in Unix-y compilers, while they would
crash straight to Qt/QtConcurrent's event loop in MSVC.

The only affected piece of code is the JPEG error catcher,
introduced by Halla in 5c4c327ad429def4eaccc8d7bbd8f70d374a51ae, so
I added a file-level workaround there. A Krita-wide workaround is not
possible at the moment; all consumers of kritapigment would need the
same surgical workaround, because OpenEXR also injects /EHsc through
its exported targets. This was already reported upstream [5].

[1]: https://api.kde.org/ecm/kde-module/KDECompilerSettings.html
[2]: https://invent.kde.org/frameworks/extra-cmake-modules/-/blob/v5.101.0/kde-modules/KDECompilerSettings.cmake#L502-526
[3]: https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/Code-Gen-Options.html#index-fexceptions
[4]: https://learn.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=msvc-170#arguments
[5]: https://github.com/AcademySoftwareFoundation/openexr/issues/1326
CCMAIL: kimageshop@kde.org

M  +4    -0    CMakeLists.txt
M  +7    -0    plugins/impex/jpeg/CMakeLists.txt

https://invent.kde.org/graphics/krita/commit/9b7b48f4da5655035497be17e516b4a826f8b54e