Bug 137495

Summary: showfoto crashes when doing any modification to a loaded directory
Product: [Applications] digikam Reporter: Fabien <fabien.ubuntu>
Component: Showfoto-WorkflowAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: ach, ahuggel, caulier.gilles, marcel.wiesweg
Priority: VHI    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 0.9.0
Sentry Crash Report:
Attachments: patch to fix file-extention parsing when it's a null string

Description Fabien 2006-11-17 17:14:49 UTC
Version:           0.4.0-svn (using KDE KDE 3.5.2)
Installed from:    Ubuntu Packages
OS:                Linux

If you try to open a directory in showfoto, it won't complain, just show a blank "photo". If you try to do any modification (filters, transformations), it will crash...
I guess there's no need for a backtrace :)

It could be great if it could load the list of pictures inside the dir, same behavior as if you do "showfoto dirname/*".
Not, when using "showfoto dirname/*", the directories should also be removed from the list.
Comment 1 caulier.gilles 2006-11-17 19:55:35 UTC
Not reproductible here. showfoto "Open Folder" run exactly like you want, normally. 

Witch KDE version you use ? Witch messages are you on the console ?

Gilles
Comment 2 Fabien 2006-11-20 11:43:47 UTC
Sorry, I wasn't precise enough.

I opened a directory in command line, eg :
# showfoto mydir/

Then, I will get a blank "photo". If then I apply any fix or filter, showfoto will crash :

<<
QFile::open: No file name specified
QFile::open: No file name specified
showfoto: /tmp : RAW file identified
showfoto: Cannot load metadata using Exiv2 (/tmp: The file contains data of an unknown image type)
showfoto: Running dcraw command (digikamdcraw,-c,-w,-a,-H,0,-b,1,-q,0,-o,1,/tmp)
showfoto: Dcraw StdErr: Cannot decode /tmp
showfoto: Cannot load metadata using Exiv2 (/tmp: The file contains data of an unknown image type)

Apply any filter or any fix then, crash

KCrash: Application 'showfoto' crashing...
>>

I did more tests and the problem is the same if you try to open a directory in "File/Open" instead of "File/Open folder".

But, the problem is not only that :

- if you open from cmdline any unsupported file or even a file that doesn't exist, you will get the same problem. Eg :
<<<
QFile::open: No file name specified
QFile::open: No file name specified
showfoto: /etc/passwd : RAW file identified
showfoto: Cannot load metadata using Exiv2 (/etc/passwd: The file contains data of an unknown image type)
showfoto: Running dcraw command (digikamdcraw,-c,-w,-a,-H,0,-b,1,-q,0,-o,1,/etc/passwd)
showfoto: Dcraw StdErr: Cannot decode /etc/passwd
showfoto: Cannot load metadata using Exiv2 (/etc/passwd: The file contains data of an unknown image type)
kio_digikamthumbnail: Cannot load metadata using Exiv2 (/etc/passwd: The file contains data of an unknown image type)
kio_digikamthumbnail: Running dcraw command dcraw -c -e '/etc/passwd'
sh: dcraw: command not found
kio_digikamthumbnail: Running dcraw command dcraw -c -h -w -a '/etc/passwd'
sh: dcraw: command not found
kio_digikamthumbnail: Running dcraw command dcraw -c -e '/etc/passwd'
sh: dcraw: command not found
kio_digikamthumbnail: Running dcraw command dcraw -c -h -w -a '/etc/passwd'
sh: dcraw: command not found
kio_digikamthumbnail: /etc/passwd : RAW file identified
kio_digikamthumbnail: Cannot load metadata using Exiv2 (/etc/passwd: The file contains data of an unknown image type)
kioslave: ####### CRASH ###### protocol = kio_digikamthumbnail pid = 30395 signal = 11
>>>


I also made some tests with a false jpeg file. Just create a text file and name it textfile.jpg
Open digikam ImageEditor on an invalid picture (textfile.jpg), you'll get an error :
Failed to load image "textfile.jpg"
But, this doesn't prevent you to apply any filter or fix

<<<

digikam: Cannot load metadata using Exiv2 (/home/fabien/Photos/2006-11-18_tests/test_ixus/textfile.jpg: The file contains data of an unknown ima
ge type)
QFile::open: No file name specified
QFile::open: No file name specified
digikam: /home/fabien/Photos/2006-11-18_tests/test_ixus/textfile.jpg : JPEG file identified
digikam: Cannot load metadata using Exiv2 (/home/fabien/Photos/2006-11-18_tests/test_ixus/textfile.jpg: The file contains data of an unknown ima
ge type)
digikam: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL
digikam: Cannot load metadata using Exiv2 (/home/fabien/Photos/2006-11-18_tests/test_ixus/textfile.jpg: The file contains data of an unknown ima
ge type)
digikam: WARNING: Failed to load image textfile.jpg
digikam: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL
digikam: CimgIface::m_resize is on, new size: (0, 0)
digikam: ::No valid image data !!! ...
digikam: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL
digikam: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL
digikam: Reading LensDistortion settings
digikam: Preview lensdistortion started...
digikam: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL
KCrash: Application 'digikam' crashing...
>>>
Comment 3 caulier.gilles 2006-11-20 15:25:54 UTC
These file must be fixed before final release.

Gilles
Comment 4 caulier.gilles 2006-11-20 16:27:29 UTC
Marcel, 

- Why 'etc/passwd' is identified like a RAW file ?

- Something is wrong in DImg::RAWLoader because dcraw fail to decode '/etc/passwd' of course, but the loader do not return false in this case...

Gilles
Comment 5 caulier.gilles 2006-11-21 15:45:13 UTC
> - Why 'etc/passwd' is identified like a RAW file ? 

Achim, this point is fixed on my computer. Because there is a lot of changes, i'm waiting 0.9.0-RC1 release before to commit.

Gilles
Comment 6 caulier.gilles 2006-11-21 15:50:34 UTC
Created attachment 18644 [details]
patch to fix file-extention parsing when it's a null string

Fabien, 

attached, a fresh patch against svn to test. Take a care than kio-slave are
fixed. You need to re-install all on your computer. 

Gilles
Comment 7 caulier.gilles 2006-11-21 16:09:52 UTC
Marcel, 

My current patch do not solve the RAWLoader problem if we trying to load a dumy raw file. The loader do not return the right value when dcraw decoding is failed.

Note: do not apply my patch to debug RAWoader, because it catch the problem...

Gilles
Comment 8 Fabien 2006-11-21 17:59:33 UTC
It looks ok for me :

1) # showfoto /etc/passwd

QFile::open: No file name specified
QFile::open: No file name specified
showfoto: /etc/passwd : QIMAGE file identified
showfoto: Cannot loading "/etc/passwd" using DImg::QImageLoader!
kio_digikamthumbnail: /etc/passwd : QIMAGE file identified
kio_digikamthumbnail: Cannot loading "/etc/passwd" using DImg::QImageLoader!
kio_digikamthumbnail: No relevant plugin found
kio_digikamthumbnail: WARNING: Cannot create thumbnail for /etc/passwd

And I can't do any action

2) # showfoto /etc

QFile::open: No file name specified
QFile::open: No file name specified
showfoto: [static Digikam::DImg::FORMAT Digikam::DImg::fileFormat(const QString&)] Failed to read header of file "/etc"
showfoto: /etc : Unknown image format !!!
kio_digikamthumbnail: [static Digikam::DImg::FORMAT Digikam::DImg::fileFormat(const QString&)] Failed to read header of file "/etc"
kio_digikamthumbnail: [static Digikam::DImg::FORMAT Digikam::DImg::fileFormat(const QString&)] Failed to read header of file "/etc"
kio_digikamthumbnail: /etc : Unknown image format !!!
kio_digikamthumbnail: No relevant plugin found
kio_digikamthumbnail: WARNING: Cannot create thumbnail for /etc
showfoto: WARNING: Failed to load image etc
showfoto: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL
showfoto: [static Digikam::DImg::FORMAT Digikam::DImg::fileFormat(const QString&)] Failed to read header of file "/etc"
showfoto: [static Digikam::DImg::FORMAT Digikam::DImg::fileFormat(const QString&)] Failed to read header of file "/etc"

And I can't do any action

3) # showfoto textfile.jpg

QFile::open: No file name specified
QFile::open: No file name specified
showfoto: /home/tests/Pictures/test02/textfile.jpg : JPEG file identified
showfoto: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
kio_digikamthumbnail: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
kio_digikamthumbnail: /home/tests/Pictures/test02/textfile.jpg : JPEG file identified
kio_digikamthumbnail: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
kio_digikamthumbnail: No relevant plugin found
kio_digikamthumbnail: WARNING: Cannot create thumbnail for /home/tests/Pictures/test02/textfile.jpg
showfoto: WARNING: Failed to load image textfile.jpg
showfoto: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL
showfoto: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)

And I can't do any action


4) Digikam Image Editor on textfile.jpg

kio_digikamthumbnail: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
kio_digikamthumbnail: /home/tests/Pictures/test02/textfile.jpg : JPEG file identified
kio_digikamthumbnail: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
kio_digikamthumbnail: No relevant plugin found
kio_digikamthumbnail: WARNING: Cannot create thumbnail for /home/tests/Pictures/test02/textfile.jpg
kio_digikampreview: Exif Orientation: 1
digikam: WARNING: Trying to append a Metadata item for an unknown key (no ItemInfo): EXIF comment
kio (KIOConnection): ERROR: Could not write data
digikam: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
digikam: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
QFile::open: No file name specified
QFile::open: No file name specified
digikam: /home/tests/Pictures/test02/textfile.jpg : JPEG file identified
digikam: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
digikam: /home/tests/Pictures/test02/textfile.jpg : JPEG file identified
digikam: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
kio_digikampreview: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
kio_digikampreview: WARNING: Cannot extract preview for /home/tests/Pictures/test02/textfile.jpg
digikam: WARNING: Failed to load image textfile.jpg
digikam: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL
digikam: Cannot load metadata using Exiv2 (/home/tests/Pictures/test02/textfile.jpg: The file contains data of an unknown image type)
digikam: WARNING: Failed to load image textfile.jpg
digikam: WARNING: [Digikam::DImg* Digikam::DImgInterface::getImg()] d->image is NULL

And I can't do any action
Comment 9 caulier.gilles 2006-11-21 18:13:19 UTC
Fabien,

In the report #4, there are 2 bad points that i can reproduce here :

> digikam: WARNING: Trying to append a Metadata item for an unknown key (no ItemInfo): EXIF comment 

Strange, normally it's "EXIFUserComment", not "EXIF comment". I suspect a KFileMetaInfo bug, but not sure. In all cal this not come from digiKam and Exiv2 library.

> kio (KIOConnection): ERROR: Could not write data 

I suspect a crash of KIO-slave (preview kioslave not thumnail kioslave)

This one will be automaticly restarted, but if you use intensivly this KIO-slave and if a crash appear, there is a risk to crash digiKam.

I think that it's a C++ exception management problem. Something is wrong somewhere, perhaps in Exiv2 when a dummy file is parsed.

Andreas, are you tested the libexiv2 (not Exiv2 command line tool) with a dummy jpeg file (for example to do "#touch dumy.jpg")

Gilles

Comment 10 Andreas Huggel 2006-11-21 18:28:52 UTC
> Andreas, are you tested the libexiv2 (not Exiv2 command line tool) with a dummy jpeg file (for example to do "#touch dumy.jpg")

It shouldn't make a difference. Class Exiv2::Image (and derived) take care of that. Exiv2 looks for a signature in the file to determine the image type (it doesn't care about the filename).

-ahu.
Comment 11 caulier.gilles 2006-11-21 18:34:58 UTC
Thanks andreas, i will look witch part in kioslave crash.

Gilles
Comment 12 Marcel Wiesweg 2006-11-21 21:35:09 UTC
Here is the patch for the rawloader problem. KProcess::normalExit() does not cover a normal exit with return status != 0.

Index: libs/dimg/loaders/rawloader.cpp
===================================================================
--- libs/dimg/loaders/rawloader.cpp     (revision 606518)
+++ libs/dimg/loaders/rawloader.cpp     (working copy)
@@ -392,7 +392,7 @@

     QMutexLocker lock(&m_mutex);
     m_running = false;
-    m_normalExit = m_process->normalExit();
+    m_normalExit = m_process->normalExit() && m_process->exitStatus() == 0;
     delete m_process;
     m_process = 0;
     delete m_queryTimer;
Comment 13 caulier.gilles 2006-11-21 22:19:04 UTC
Both patch have been commited to svn. 

I close this file now.

Gilles