Bug 432129

Summary: libusb-compat: f-spot crashes on first launch and when importing
Product: [openSUSE] openSUSE 11.1 Reporter: Mark Gordon <mtgordon>
Component: GNOMEAssignee: Marcus Meissner <meissner>
Status: RESOLVED FIXED QA Contact: E-mail List <nld10-bugs-qa>
Severity: Minor    
Priority: P4 - Low CC: captain.magnus, ke, sbrabec, vuntz
Version: Beta 2   
Target Milestone: Future/Later   
Hardware: i586   
OS: SUSE Other   
Whiteboard:
Found By: System Test Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: first launch crash spewage
import crash spewage
stack trace from gdb, with gphoto/libgphoto2 debuginfo installed

Description Mark Gordon 2008-10-03 15:29:36 UTC
When first run for a new user, f-spot crashes on launch.  If I rm -rf ~/.gnome2/f-spot, I can reproduce the first launch crash.  Subsequently, if I start f-spot and try to import, it crashes.  On the (possibly erroneous) assumption that there's a common underlying cause, I'm going to file only one bug.  Feel free to split it out if I'm mistaken.

Spewage attachments to follow.
Comment 1 Mark Gordon 2008-10-03 15:31:00 UTC
Created attachment 243393 [details]
first launch crash spewage
Comment 2 Mark Gordon 2008-10-03 15:31:56 UTC
Created attachment 243394 [details]
import crash spewage

Note: all I did was click the Import button.  No actual importing was involved.
Comment 3 Mark Gordon 2008-10-03 16:05:25 UTC
Oops, actually found in Beta 2.
Comment 4 JP Rosevear 2008-10-06 20:14:13 UTC
I'm unable to replicate this.
Comment 5 Stephane Delcroix 2008-10-06 20:45:39 UTC
Mark was able to trigger this bug using "gphoto2 -a":
 
libusb couldn't open USB device /dev/bus/usb/001/001: Permission denied.
libusb requires write access to USB device nodes.
Segmentation fault

Not directly f-spot related, and there's nothing we can do to catch this inside f-spot (unfortunately, crashes in native code results in vm crashes)
Comment 6 Marcus Meissner 2008-10-07 19:47:22 UTC
It should not crash either way.

can you get a backtrace from gphoto2 -a  using gdb and debuginfos? 
Comment 7 Mark Gordon 2008-10-07 21:50:25 UTC
No, I can't.  I have no idea where to find debuginfo packages for the beta.
Comment 8 Mark Gordon 2008-10-07 22:05:18 UTC
Created attachment 244117 [details]
stack trace from gdb, with gphoto/libgphoto2 debuginfo installed

OK, I found them.
Comment 9 Marcus Meissner 2008-10-08 06:26:10 UTC
puzzling.

seems the new libusb, will check
Comment 10 Marcus Meissner 2008-10-08 13:20:53 UTC
submitted fixed libusb-compat to Factory.
Comment 11 Stephane Delcroix 2008-10-09 09:20:31 UTC
Confirmed on os11.1b2 x86_64 out of the box
Comment 13 Marcus Meissner 2008-10-13 15:47:09 UTC
stanislav, i had to add more NULL ptr checks, they are in
the same patch (fix-ctx-NULL.patch). ... can you also send them upstream?
Comment 14 Marcus Meissner 2008-10-15 06:37:00 UTC
*** Bug 435133 has been marked as a duplicate of this bug. ***
Comment 15 JP Rosevear 2008-10-22 19:27:42 UTC
*** Bug 436753 has been marked as a duplicate of this bug. ***
Comment 16 Stanislav Brabec 2008-11-05 15:49:32 UTC
I got a reply from upstream considering the fix possibly incorrect.

Reopening and decreasing to Normal to resolve this issue correctly. Changing the product to openSUSE to make it visible for upstream.

From: Daniel Drake <dsd@gentoo.org>
Cc: libusb-devel@lists.sourceforge.net
Subject: Re: [Libusb-devel] libusb-compat: Fix crash if usb not initialized (more crashes fixed)
Date: Sun, 02 Nov 2008 21:53:34 +0000 (22:53 CET)

Stanislav Brabec wrote:
> Stanislav Brabec wrote:
>> Attached patch fixes crash, if USB is not initialized.
> 
> And attached update fixes even more crashes, if USB is not initialized.
> It replaces previous one.

Thanks for the patch!

>> Affected application: F-Spot
>> Author: Marcus Meissner <meissner@suse.de>
>> Reference: https://bugzilla.novell.com/show_bug.cgi?id=432129

I have to sign up to see this bug report?

 From the 1 line description, it sounds like a F-Spot bug using libusb 
before it's initialized. I'm interested in matching the behaviour of 
libusb-0.1.12, but only if we do it precisely, which your patch doesn't 
quite do. For example, usb_close() on a NULL pointer will cause 
libusb-0.1.12 to crash, whereas your patch makes libusb-compat return 
-EINVAL.

Also, nitpicking: there are some coding style flaws, please try and 
match the rest of the file. Some of the patch is fine, some uses spaces 
for indentation and has 'if' conditions and bodies on the same line.

cheers
Daniel

Comment 17 Marcus Meissner 2008-11-05 16:09:23 UTC
Hmm.

I just went through all instances dereferencing the pointers. Some of them might be not necessary (like usb_open mentioned).
Comment 18 Stanislav Brabec 2008-11-05 17:19:04 UTC
Here is a reply from Daniel Drake:

Stanislav Brabec wrote:
> Daniel Drake wrote:
>> From the 1 line description, it sounds like a F-Spot bug using libusb 
>> before it's initialized.
> 
> It may be a f-spot programming bug, which was hidden with libusb-0.1
> somehow. I am reopening it, so f-spot maintainers could review it.

If your "patch" fixes it, it sounds like it will just avoid a crash, and 
not actually fix the broken functionality.

>> I'm interested in matching the behaviour of 
>> libusb-0.1.12, but only if we do it precisely, which your patch doesn't 
>> quite do. For example, usb_close() on a NULL pointer will cause 
>> libusb-0.1.12 to crash, whereas your patch makes libusb-compat return 
>> -EINVAL.
> 
> So call abort() or so, isn't it?

I would just leave it as it was, which will crash. That's the same as 
libusb-0.1.

I would suggest finding the cause of your crash (which function in 
libusb-0.1 can be called before usb_init that doesn't crash) and 
matching behaviour there (if possible), and then looking for any similar 
cases, without being too bold.

Thanks,
Daniel
Comment 19 Stanislav Brabec 2008-11-12 16:43:45 UTC
libusb-compat is not bug compatible with libusb0.

Reverting to libusb0, removing upper mentioned patch from libusb-compat.

Keeping this bug open and reassigning to GNOME team. It most probably indicates double close bug in f-spot.

Applications can still be built against libusb-1.0 using libusb-compat-devel instead of libusb-devel.
Comment 20 Stanislav Brabec 2008-11-12 17:37:19 UTC
See bug 443861 for the whole story.
Comment 21 Hubert Figuiere 2008-11-21 17:21:52 UTC
gphoto upstream bug https://sourceforge.net/tracker2/?func=detail&atid=108874&aid=2321764&group_id=8874
Comment 22 Vincent Untz 2009-09-18 22:28:02 UTC
(In reply to comment #19)
> libusb-compat is not bug compatible with libusb0.
> 
> Reverting to libusb0, removing upper mentioned patch from libusb-compat.
> 
> Keeping this bug open and reassigning to GNOME team. It most probably indicates
> double close bug in f-spot.
> 
> Applications can still be built against libusb-1.0 using libusb-compat-devel
> instead of libusb-devel.

Hrm, but f-spot doesn't link to libusb AFAIK (at least, according to rpm -q --requires). So, hrm, should the bug really be in the GNOME team's hands?
Comment 23 Stanislav Brabec 2009-09-21 13:23:04 UTC
See comment 19. Well, the problem may still exist in gphoto.

The crash was worked-around by return to libusb0 and later fixed in libusb-compat.

But the crash itself most probably indicates double close on error bug in gphoto.

Marcus, could you check gphoto code (of openSUSE 11.1)? If you think that the code is OK, feel free to close this bug.
Comment 24 Marcus Meissner 2009-09-21 14:03:46 UTC
11.2 Milestone7 ... f-sport works fine.

I did of course all gphoto2 apps with the new libusb ;)
f-spot crashed last week, but it does not