[Libusbx-devel] Reverting atexit call of libusb_exit from libusb-compat ?

2013-09-04 Thread Hans de Goede
Hi,

As discussed in much detail here:
https://bugzilla.redhat.com/show_bug.cgi?id=1003193

Calling libusb_exit from atexit from libusb-compat-0.1.5 causes
some apps to break.

The app in question is the scanimage app from sane-backends, which
uses atexit for cleanup itself.

So what happens is the libusb-compat atexit handler runs first, and
then the scanimage atexit cleanup code runs, and tries to cleanly
shutdown the scanner (which may require communicating to it).

This results in logs with LIBUSB_DEBUG=4 like this:

[ 9.641307] [6300] libusbx: debug [libusb_exit]
[ 9.641312] [6300] libusbx: debug [libusb_exit] destroying default context
[ 9.641317] [6300] libusbx: warning [libusb_exit] application left some 
devices open
libusbx: warning [add_to_flying_list] failed to arm first timerfd (errno 9)
libusbx: warning [add_to_flying_list] failed to arm first timerfd (errno 9)
libusbx: warning [add_to_flying_list] failed to arm first timerfd (errno 9)
libusbx: warning [libusb_close] internal signalling write failed, closing anyway
scanimage: received signal 2
scanimage: trying to stop scanner
libusbx: warning [add_to_flying_list] failed to arm first timerfd (errno 9)
libusbx: warning [add_to_flying_list] failed to arm first timerfd (errno 9)
libusbx: warning [add_to_flying_list] failed to arm first timerfd (errno 9)
scanimage: received signal 2
scanimage: aborting

Note that errno 9 is EBADFD, which is caused by the fd already being closed
by libusb_exit.

I consider this behavior with some old apps a way bigger problem then the
memory / resource leak we had before, therefor I suggest reverting the
atexit changes to libusb-compat.

Regards,

Hans

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


Re: [Libusbx-devel] Reverting atexit call of libusb_exit from libusb-compat ?

2013-09-04 Thread Xiaofan Chen
On Thu, Sep 5, 2013 at 3:26 AM, Hans de Goede  wrote:
> Hi,
>
> As discussed in much detail here:
> https://bugzilla.redhat.com/show_bug.cgi?id=1003193
>
> Calling libusb_exit from atexit from libusb-compat-0.1.5 causes
> some apps to break.
>
> The app in question is the scanimage app from sane-backends, which
> uses atexit for cleanup itself.
>
> So what happens is the libusb-compat atexit handler runs first, and
> then the scanimage atexit cleanup code runs, and tries to cleanly
> shutdown the scanner (which may require communicating to it).
> ...
> I consider this behavior with some old apps a way bigger problem then the
> memory / resource leak we had before, therefor I suggest reverting the
> atexit changes to libusb-compat.
>

I agree.

On the other hand, maybe we then have to document this limitation
of libusb-compat.

BTW, do we need to replicate the libusb.org libusb-compat tickets in
libusbx github? Only Ticket 110 and 32 need to be copied as other
tickets have been closed.
 http://www.libusb.org/report/10

If yes, then I will copy the two tickets and add "Compat" in the
beginning of the description to distinguish them from libusbx tickets.



-- 
Xiaofan

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel