Bug 372093 - corrupts image file when crashing
Summary: corrupts image file when crashing
Status: RESOLVED WORKSFORME
Alias: None
Product: digikam
Classification: Applications
Component: Portability-Runtime (show other bugs)
Version: 4.12.0
Platform: Kubuntu Linux
: NOR major
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-05 00:34 UTC by Kai
Modified: 2017-08-10 20:02 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.4.0


Attachments
corrupted example jpg (896.00 KB, image/jpeg)
2016-11-27 23:55 UTC, Kai
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kai 2016-11-05 00:34:07 UTC
After having seen a few mid-work crashes, some image files are corrupted in the sense that they load, but only contain the upper part of the image. It seems the write to the image file stopped mid-file, presumably caused by a program crash.

In most of the crash situations digikam was in the process of changing metadata to a bunch of images. My guess is that it was not only changing this metadata in its database, but also inside the image files itself. When the process crashes while rewriting an image file, this file doesn't seem to be protected against corruption. (I. e. it seems the file gets overwritten directly instead of writing a copy and replacing the former file only when he new copy was written correctly.)

[NB: It would take me weeks to find my way through the source code. If someone might point me to the src file taking care of overwriting image file in the relevant cases, I _might_ be able to submit a code proposal.]
Comment 1 caulier.gilles 2016-11-05 06:21:47 UTC
What do you do exactly to reproduce this dysfunction ?

Which version of digiKam you use ?

Which kind of image type mime you process exactly ? JPEG ? RAW ? TIFF ? PNG ?

Metadata are not processed directly by digiKam but in low level by Exiv2 shared lib. Which version do you use ? Look in Help/Components Info for details.

Image is always processed on a copy by Exiv2. Never on original directly. Also, image data are not touch by Exiv2, only the metadata chunk. So you kind of corruption is strange.

Run digiKAm on a console. Which debug trace do you seen when you can reproduce the problem ?

Try also to localize which image file can be used to reproduce the problem...

In all cases, the relevant code will be certainly located in Exiv2, not in digiKam...

Gilles Caulier
Comment 2 caulier.gilles 2016-11-05 06:27:27 UTC
Also try with current digiKam 5.3.0 AppImage bundle for Linux, to see if problem still reproducible...

https://drive.google.com/open?id=0BzeiVr-byqt5Y0tIRWVWelRJenM

Gilles Caulier
Comment 3 Kai 2016-11-05 23:50:19 UTC
I only worked with JPGs in that case.
It will be a few days before I have access to that computer again. I'm going to add all the version details then.
Comment 4 caulier.gilles 2016-11-25 14:33:37 UTC
Did you try with DK AppImage bundle given at the url :

https://drive.google.com/drive/folders/0BzeiVr-byqt5Y0tIRWVWelRJenM

Gilles Caulier
Comment 5 Kai 2016-11-27 23:55:40 UTC
Created attachment 102484 [details]
corrupted example jpg

corrupted example jpg
Comment 6 Kai 2016-11-27 23:56:25 UTC
sorry for taking this long

I got the version from the kubuntu-backports for ubuntu trusty, which - sadly - is v. 4.0.0 (cannot set this version number in the metadata of this bug entry). LibExiv2 is tagged with version 0.23 here.

Up to now I only used this version that I can install from packages sources.

Nonetheless I uploaded a <1M corrupted jpg file to demonstrate what I'm trying to describe (the file should be 5M to 8M).
Comment 7 caulier.gilles 2016-11-28 05:29:58 UTC
No.

Please use the AppImage Bundle for Linux and forget DK from your system, as i said in comment #4.

The AppImage do not install anything and have the last libraries mandatory for DK embedded inside. For ex, Exiv2 is 0.26-rc...

Gilles Caulier
Comment 8 Kai 2016-11-28 23:23:48 UTC
Seems fair enough. I'll try that way.
please close this bug report as "outdated", "not a bug", or something like this (seems I cannot switch to theses states myself - only to resolved)
Thanks for bothering!