lxman | 1 Jul 2010 04:18
Picon

Re: libusb_handle_events() crashing


This might help - while I was trying to shuffle code around and pinpoint a
little closer what is going on, my debugger dropped me (just before the app
crashed) into libusb_get_next_timeout.  The point in the code where it
stopped was here:

	pthread_mutex_lock(&ctx->flying_transfers_lock);
	if (list_empty(&ctx->flying_transfers)) {
		pthread_mutex_unlock(&ctx->flying_transfers_lock);
		usbi_dbg("no URBs, no timeout!");
-->		return 0;
	}

Maybe that will give a closer idea of what is going on to someone who knows
libusb more intimately.
--

-- 
View this message in context: http://libusb.6.n5.nabble.com/libusb-handle-events-crashing-tp512231p512265.html
Sent from the LibUSB Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Xiaofan Chen | 1 Jul 2010 04:29
Picon

Re: libusb_handle_events() crashing

On Thu, Jul 1, 2010 at 3:22 AM, lxman <jordan.mymail <at> gmail.com> wrote:

> Whenever I come to trying to execute libusb_handle_events, the application
> segfaults.
>
> Any ideas?

It would help that you tell the version of libusb-1.0 and OS version
you are using.

And since it segfaults, probably you can fire up gdb and get the
backtrace.

--

-- 
Xiaofan http://sourceforge.net/projects/libusb-win32/

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
lxman | 1 Jul 2010 04:33
Picon

Re: libusb_handle_events() crashing


libusb-1.0.8

linux 2.6.31.13 kernel
--

-- 
View this message in context: http://libusb.6.n5.nabble.com/libusb-handle-events-crashing-tp512231p512267.html
Sent from the LibUSB Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
lxman | 1 Jul 2010 19:37
Picon

Re: libusb_handle_events() crashing


OK, ran a backtrace in gdb - received the following:

#0  libusb_get_next_timeout (ctx=0x1d9a, tv=0xbfab22d8) at io.c:2097
#1  0xb782fdfe in get_next_timeout (ctx=0x1d9a, tv=0xbfab2368,
out=0xbfab2328) at io.c:1886
#2  0xb7830b78 in libusb_handle_events_timeout (ctx=0x1d9a, tv=0xbfab2368)
at io.c:1929
#3  0xb7830cb2 in libusb_handle_events (ctx=0x1d9a) at io.c:1981
#4  0x0804a548 in Calculator::init_bulk_in (this=0x91461c0)
    at ../include/Calculator.cpp:130
#5  0x0804a365 in Calculator::init (this=0x91461c0) at
../include/Calculator.cpp:97
#6  0x08048f20 in main (argc=2, argv=0xbfab24e4) at calctest.cpp:31
--

-- 
View this message in context: http://libusb.6.n5.nabble.com/libusb-handle-events-crashing-tp512231p512433.html
Sent from the LibUSB Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
lxman | 1 Jul 2010 23:21
Picon

Re: libusb_handle_events() crashing


Okay, I discovered that the callback function was not being passed properly
so I have switched to a non-member function outside of the class.  But
libusb is still crashing in what appears to be the libusb_get_next_timeout
function.  Here's a full backtrace from gdb if anyone can help.

#0  libusb_get_next_timeout (ctx=0x1d9a, tv=0xbf89cc48) at io.c:2097
        transfer = <value optimized out>
        cur_ts = {tv_sec = -1081488168, tv_nsec = -1081488232}
        r = <value optimized out>
        __FUNCTION__ = "libusb_get_next_timeout"
#1  0xb770bdfe in get_next_timeout (ctx=0x1d9a, tv=0xbf89ccd8,
out=0xbf89cc98) at io.c:1886
        timeout = {tv_sec = -1217366448, tv_usec = -1217149992}
        r = <value optimized out>
#2  0xb770cb78 in libusb_handle_events_timeout (ctx=0x1d9a, tv=0xbf89ccd8)
at io.c:1929
        r = <value optimized out>
        poll_timeout = {tv_sec = 0, tv_usec = 0}
        __FUNCTION__ = "libusb_handle_events_timeout"
#3  0xb770ccb2 in libusb_handle_events (ctx=0x1d9a) at io.c:1981
        tv = {tv_sec = 60, tv_usec = 0}
#4  0x0804a5a0 in Calculator::init_bulk_in (this=0x93891c0)
    at ../include/Calculator.cpp:135
        ret = 1
        buf = (unsigned char *) 0x9389250 ""
        pkt = (libusb_transfer *) 0xbf89cd10
        curr_item = 0
        trnsfr = {dev_handle = 0x9389200, flags = 0 '\0', endpoint = 129
'\201',
(Continue reading)

lxman | 2 Jul 2010 00:05
Picon

Re: libusb_handle_events() crashing


Found it.  I was passing a bad context pointer.

Thanks for the help.
--

-- 
View this message in context: http://libusb.6.n5.nabble.com/libusb-handle-events-crashing-tp512231p512473.html
Sent from the LibUSB Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Ludovic Rousseau | 2 Jul 2010 13:19
Picon
Gravatar

libusb-1.0.9 soon?

Hello Daniel and all,

Bugs have been reported and either corrected or patches are available
since libusb-1.0.8 is out. Is there a plan to release libusb-1.0.9
with all the improvements?

In particular I am interested in the following changes and fixes:
- libusb_strerror() now available
- fix for the "usbfs: usb_submit_urb returned -121" problem [1]
- fix to make the sync API safe in multithread applications [2]

I attach (again) the two patches for the 2 fixes. They are _not yet_
included and have not received much discussion on the mailing list.

I guess other fixes already included in the git repository would
benefit to every one.

Are we waiting for something to be merged or fixed before releasing 1.0.9?

Regards,

[1] http://comments.gmane.org/gmane.comp.lib.libusb.devel.general/10850
[2] http://comments.gmane.org/gmane.comp.lib.libusb.devel.general/10913

--

-- 
 Dr. Ludovic Rousseau
(Continue reading)

Peter Stuge | 2 Jul 2010 13:45
Picon

Re: libusb-1.0.9 soon?

Ludovic Rousseau wrote:
> - fix for the "usbfs: usb_submit_urb returned -121" problem [1]
..
> I attach (again) the two patches for the 2 fixes.

Please do not mangle the author information of the patch when
resending. Either use git am to apply patches from email which makes
sure that author information in the commit does not disappear, or if
you can't use git am, then please make sure to use --author when
running git commit. Thank you.

> They are _not yet_ included and have not received much discussion
> on the mailing list.

I think the one I made is a fairly straightforward bugfix. The other
one might need some discussion, since it changes the API a little.

//Peter

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Xiaofan Chen | 2 Jul 2010 14:08
Picon

Re: libusb-1.0.9 soon?

On Fri, Jul 2, 2010 at 7:19 PM, Ludovic Rousseau
<ludovic.rousseau <at> gmail.com> wrote:
> Hello Daniel and all,
>
> Bugs have been reported and either corrected or patches are available
> since libusb-1.0.8 is out. Is there a plan to release libusb-1.0.9
> with all the improvements?

I would really hope that libusb-1.09 will be able to integrate
the Windows backend even though the Windows backend
will really be labeled as experimental or beta.

--

-- 
Xiaofan

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Ludovic Rousseau | 2 Jul 2010 14:49
Picon
Gravatar

Re: libusb-1.0.9 soon?

2010/7/2 Peter Stuge <peter <at> stuge.se>:
> Ludovic Rousseau wrote:
>> - fix for the "usbfs: usb_submit_urb returned -121" problem [1]
> ..
>> I attach (again) the two patches for the 2 fixes.
>
> Please do not mangle the author information of the patch when
> resending. Either use git am to apply patches from email which makes
> sure that author information in the commit does not disappear, or if
> you can't use git am, then please make sure to use --author when
> running git commit. Thank you.

Sorry for that. I am not yet a git "normal" user.
The original patches are available at

http://sourceforge.net/mailarchive/message.php?msg_name=20100625230400.16673.qmail%40stuge.se

and

http://sourceforge.net/mailarchive/message.php?msg_name=4BD920C5.3090909%40argyllcms.com

Bye

--

-- 
 Dr. Ludovic Rousseau

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
(Continue reading)


Gmane