Bug 156420 - Canon EOS 400D, no thumbnails displayed then digikam segfaults
Summary: Canon EOS 400D, no thumbnails displayed then digikam segfaults
Status: RESOLVED WORKSFORME
Alias: None
Product: digikam
Classification: Applications
Component: Import-IconView (show other bugs)
Version: unspecified
Platform: FreeBSD Ports FreeBSD
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-22 23:13 UTC by Mark Ovens
Modified: 2017-08-16 05:17 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 0.9.4


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Ovens 2008-01-22 23:13:12 UTC
Version:           0.9.3 (using KDE 3.5.8)
Installed from:    FreeBSD Ports
Compiler:          gcc 3.4.6 
OS:                FreeBSD

Follow on from my post in the mailing list - http://mail.kde.org/pipermail/digikam-users/2008-January/004805.html

Running 0.9.3 under KDE 3.5.8 on FreeBSD 6.3

When I connect my Canon EOS400D (PTP Mode) the OS reports it as:

ugen0: Canon Inc. Canon Digital Camera, rev 2.00/0.02, addr 2

In digikam I connect to the camera, the camera window opens, displays 
"Connecting to camera", 'BUSY' appears on the camera LCD screen and the 
read/write LED flashes. Digikam then displays "Listing Folders....".

When digikam has finished, there are no thumbnails displayed but the 
following appears in the console:

digikam: Failed to get folders list from camera!
digikam: Libgphoto2 error: Unspecified error (-1)

Then, when I click 'Close' in the camera window in digikam, this appears 
in the console and digikam dies on a SIGSEGV:

KCrash: Application 'digikam' crashing...

The following library versions are being used:

libgphoto2  2.4.0
kipi-plugins 0.1.4
exiv2 0.14
lcms 1.17
dcraw 8.81

It was suggested that gphoto2 may be the cause (Canon problems in 2.4.0) so I downgraded gphoto2 to 2.2.1 but the problem persisted.

I then downgraded digikam back to 0.9.2 and it works correctly - even with gphoto2 2.4.0 - so it definitely seems to be a problem with digikam 0.9.3

I've done some limited debugging (using fprintf()s in both the digikam and gphoto2 code) and the problem seems to be in camlibs/ptp2/library.c at around line 2578:

                 PTPStorageIDs storageids;

        if (ptp_operation_issupported(params,PTP_OC_GetStorageIDs)) {
fprintf(stderr, ">> 2\n");
                         CPR (context, ptp_getstorageids(params,
                                 &storageids));
fprintf(stderr, ">> Returned from ptp_getstorageids()\n");
                         for (i=0; i<storageids.n; i++) {
                                 char fname[PTP_MAXSTRLEN];


The fprintf()'s are my debug and it never gets to the second one so it appears to never return from ptp_getstorageids() - although this is using an optimized build rather than a debug build so may be misleading.
Comment 1 caulier.gilles 2008-01-23 10:31:51 UTC
Marcus, 

What do you think about this report ?

Gilles
Comment 2 Mark Ovens 2008-01-23 11:48:12 UTC
Comments posted in the mailing list thread show that this works on Linux so it appears to be a FreeBSD-specific issue.

I'll post on the FreeBSD Ports mailing list about it. I'll close this bug if it does turn out to be a FBSD Ports issue.
Comment 3 Marcus Meissner 2008-01-23 17:06:54 UTC
it should not crash there.

Can you reproduce with the commandline client ( gphoto2 -L ) ?
Comment 4 Mark Ovens 2008-01-23 19:15:55 UTC
Hi Marcus,

No, the commandline client works just fine:

/usr/ports/graphics/digikam/work/digikam-0.9.3{120}# gphoto2 --auto-detect -L
Model                          Port
----------------------------------------------------------
Canon EOS 400D (PTP mode)      usb:

There is no file in folder '/'.
There is no file in folder '/store_00000001'.
There is no file in folder '/store_00000001/DCIM'.
There are 196 files in folder '/store_00000001/DCIM/100CANON'.
#1     IMG_0001.JPG                 3804 KB 3888x2592 image/jpeg
#2     IMG_0002.JPG                 4729 KB 3888x2592 image/jpeg
#3     IMG_0003.JPG                 5146 KB 3888x2592 image/jpeg
#4     IMG_0004.JPG                 2772 KB 3888x2592 image/jpeg

[snip]

#193   IMG_0201.JPG                 3327 KB 3888x2592 image/jpeg
#194   IMG_0202.JPG                 3518 KB 3888x2592 image/jpeg
#195   IMG_0203.JPG                 3518 KB 3888x2592 image/jpeg
#196   IMG_0204.JPG                 3758 KB 3888x2592 image/jpeg
/usr/ports/graphics/digikam/work/digikam-0.9.3{121}#

Comment 5 Marcus Meissner 2008-01-23 21:27:18 UTC
The CPR() is a preprocessor define which returns on failure.

However, gphoto2 -L works fine, so this code should not return failure.
You can try "gphoto2 -T" to download all thumbnails, and "gphoto2 -P" to download all images, but I suspect this will just work too.

What also could be are multiple calls to gphoto2 in a row :/

Not sure.:/
Comment 6 Mark Ovens 2008-01-24 00:50:08 UTC
>> You can try "gphoto2 -T" to download all thumbnails, and "gphoto2 -P" to download all images, but I suspect this will just work too.

Yes, they work fine too.

digikam fails in GPCamera::getSubFolders() here:

    errorCode = gp_camera_folder_list_folders(d->camera, QFile::encodeName(folder), clist, m_status->context);
    if (errorCode != GP_OK) 
    {
        DDebug() << "Failed to get folders list from camera!" << endl;

Since gphoto2 works OK could this mean that the problem is with what is being passed to gp_camera_folder_list_folders() ?
Comment 7 Vic 2008-01-27 03:30:12 UTC
I got same problem with Canon-400D after update from digikam-0.9.2 to digikam-0.9.3
Comment 8 Marcus Meissner 2008-01-27 17:48:18 UTC
I am at loss a bit, because the code looks good. :/
Comment 9 Mark Ovens 2008-01-28 13:52:59 UTC
Vic, which OS are you using?
Comment 10 Vic 2008-02-09 20:38:25 UTC
>Vic, which OS are you using?

[vic@vic-home: ./digikam] $ uname -a
FreeBSD vic-home.stream.net.ua 6.3-RELEASE FreeBSD 6.3-RELEASE #2: Sun Feb  3 16:24:19 EET 2008     root@vic-home.stream.net.ua:/usr/obj/usr/src/sys/W_STATION  i386

I think problem not in OS.
I update to FreeBSD 6.3 one week ago.


Comment 11 Vic 2008-02-09 20:42:32 UTC
Marcus, I'm familiar with C/C++ and KDE,
so if you help me and say what module need to debug I can do it.

Or I can run FreeBSD + VNC for you once day and you can try debug project
online. 
Comment 12 caulier.gilles 2008-03-18 12:28:49 UTC
Marcus, Vic,

What's news about this entry ? Some progress ?

Gilles Caulier
Comment 13 Vic 2008-03-18 12:50:37 UTC
I continue using digikam-0.9.2.....
Comment 14 Arnd Baecker 2008-03-19 07:22:55 UTC
Mark and Vic, following Marks comment #c6 could you maybe add some  
   DWarning() << ... << endl;
statements before the call to gp_camera_folder_list_folders
which display the parameters passed to that routine?
Maybe also the error code could give an indication about what is going on?

Best, Arnd
Comment 15 Mark Ovens 2008-03-21 16:42:01 UTC
Arnd, you'll need to help me out a bit here - I'm not too hot on C++ and can't work out how to dereference these pointers to display the data.

I've added this:

DWarning() << "d->camera: " << d->camera << endl;
DWarning() << "QFile::encodeName(folder): " << QFile::encodeName(folder) << endl;
DWarning() << "clist: " << clist << endl;
DWarning() << "m_status->context: " << m_status->context << endl;

which produces this output:

digikam: WARNING: d->camera: 0x8967a80
digikam: WARNING: QFile::encodeName(folder): /
digikam: WARNING: clist: 0x8a43000
digikam: WARNING: m_status->context: 0x8a32200

Not much use I guess?

Oneother thing I've noticed is that once DK has accessed the camera once, it can't find it again unless I disconnect and reconnect it. This occurs even when using Auto-detect in the Camera dialogue. However, using ``gphoto --auto-detect'' from the commandline works repeatedly without dis-/re-connecting the camera.
Comment 16 Mark Ovens 2008-06-13 19:07:45 UTC
The problem has been found, and fixed. It was a problem in libusb on FreeBSD. Since the version of that library I was using was the same for 0.9.2 and 0.9.3 I can only assume that some changes in digikam exposed the bug in libusb.

Anyway, a huge thank you to Markus Brueffer who responded to a post I made on the FreeBSD mailing lists asking for help debugging this. He was having similar problems with his Nikon D60 and came up with the fix which I have tested and confirmed that it also fixes my problem:

I'll include two messages from Markus here for completeness in case anyone else looks at this bug:

> > Anyway, digikam has severe problems with the Nikon D60 as well (only
> > partly downloading images, camera not accessible after downloading and
> > failing on some images, etc). Although these are different than your
> > specific problem, the actual cause of the problem is probably the same as
> > digikam 0.9.2 works just fine.

> I finally found the cause of the problem (at least the one that happens here 
> with the Nikon D60, but I'm confident that it's the cause of yours as well). 
> What happens is the following: 
> 
> When downloading data form the camera, digikam invokes usb_bulk_read from 
> libusb through the libgphoto2 functions. usb_bulk_read uses read(2) to get 
> data from the camera. read(2) now gets interrupted by a signal (SIGCHLD) that 
> gets delivered to digikam and returns with EINTR, which is the actual cause 
> of the problem. The attached patch for libusb suspends signal delivery during 
> bulk reads and writes for SIGCHLD which lets read(2) succeed and the signal 
> gets delivered to digikam after the read(2) call.

Comment 17 Mark Ovens 2008-06-13 19:08:45 UTC
Closing this bug as it is now no longer an issue.