Bug 408592 - "Broken PNG Image" cause digiKam to crash under Windows 64 bit
Summary: "Broken PNG Image" cause digiKam to crash under Windows 64 bit
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-DImg-PNG (show other bugs)
Version: 6.1.0
Platform: Microsoft Windows Microsoft Windows
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-11 23:58 UTC by Ariangga
Modified: 2020-08-01 20:17 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.1.0


Attachments
The corrupt png (1.91 MB, image/png)
2019-06-11 23:58 UTC, Ariangga
Details
setjmp.patch (5.48 KB, patch)
2019-06-12 20:29 UTC, Maik Qualmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ariangga 2019-06-11 23:58:14 UTC
Created attachment 120809 [details]
The corrupt png

I have a large amount of photos library, about 16K or so,
At first, importing all the folder seems fine,
Then to make the thumbnail load faster I did the tool-> maintenance -> rebuild thumbnail ("with scan for changed" checked).
It somehow keep crash after certain amount of percentage,

Long story short, I import each folder manually, then I found 1 png file than cause DigiKam to crash whenever I add that file to the collection/folder,

The png file seems fine and can be opened by windows 10 default photo library, BUT when I open it on Photoshop it show "IDAT:incorrect data check". I assume that the png image is corrupt,

I attached the png file,

STEPS TO REPRODUCE
1. Add the attached png file to album/folder
2. Run maintenance -> Rebuild thumbnail (Checked "scan for change")

OBSERVED RESULT
This file always crashed DigiKam

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Maik Qualmann 2019-06-12 06:11:53 UTC
Our error message "Internal libPNG error during reading file. Process aborted!" is not output under Windows. It looks like the error handling with setjmp/longjmp is not working. Maybe libpng has been compiled with PNG_SETJMP_NOT_SUPPORTED?

Maik
Comment 2 caulier.gilles 2019-06-12 07:28:59 UTC
Maik, 

Under Windows with MXE, the libpng rules are in this script :

https://github.com/mxe/mxe/blob/master/src/libpng.mk

There is no PNG_SETJMP_NOT_SUPPORTED passed as compilation flag...

Gilles
Comment 3 Ariangga 2019-06-12 07:43:18 UTC
Update,
Everyone, thank you for your respond,
So I open the png file on Autodesk Sketchbook then save as new file from it, then it solved, digiKam don't crash anymore with the new png file
Comment 4 Maik Qualmann 2019-06-12 10:35:59 UTC
OK, the cause is clear. When we install digiKam in the 32 bit version on a 64 bit Windows, everything works as expected. The PNG loader breaks off correctly and the error message is in the log and there is no crash. The cause is this bug in MinGW-w64:

https://sourceforge.net/p/mingw-w64/bugs/406/

This also explains further crashes with digiKam under Windows.

Maik
Comment 5 Maik Qualmann 2019-06-12 20:29:45 UTC
Created attachment 120825 [details]
setjmp.patch

One possibility is probably the use of the built-in GCC alternative __builtin_setjmp and __builtin_longjmp. I already provide the patch. The GDB Bugtrace shows that it crashes in libpng in the longjmp() function (jump into the msvcrt.dll, also confirmed by reports in the net) So we also have to patch the libpng.

Maik
Comment 6 caulier.gilles 2019-06-24 09:41:38 UTC
Maik,

What's we can do with your patch ?

It touch the DK image loaders. If they can be used as well, it's fine for me to commit and include change in Windows bundles.

If libPNG need a patch too, it's more complicated as the patch must be sent to MXE team through github for normal UPSTREAM.

Gilles
Comment 7 Maik Qualmann 2019-06-24 10:26:45 UTC
It should help for the JPG loader, but I will still test with a defective image. Exactly, libpng has a different error handling, the longjmp part is in the libpng, it should be patched. Should it work for the JPG loader, I will already use part of the patch.

Maik
Comment 8 Maik Qualmann 2019-06-28 19:52:22 UTC
*** Bug 406979 has been marked as a duplicate of this bug. ***
Comment 9 Maik Qualmann 2019-09-11 08:39:23 UTC
*** Bug 411763 has been marked as a duplicate of this bug. ***
Comment 10 caulier.gilles 2020-08-01 14:25:29 UTC
digiKam 7.0.0 stable release is now published and now available as FlatPak:

https://www.digikam.org/news/2020-07-19-7.0.0_release_announcement/

We need a fresh feedback on this file using this version.

Thanks in advance

Gilles Caulier
Comment 11 caulier.gilles 2020-08-01 20:17:38 UTC
Problem fixed as reported in bug #406979