libusb/pyusb segmentation fault

307 views
Skip to first unread message

zbuhman

unread,
Jul 31, 2011, 8:32:46 PM7/31/11
to nxt-python
Though I'm not exactly sure what's going on,
"usb.backend.libusb10:_LibUSB.get_configuration(None)" looks awefully
suspicious.

http://paste.pocoo.org/show/450231/

lejos, which also uses libusb, works just fine for me (so I would
assume my system is configured correctly).

Marcus Wanner

unread,
Aug 1, 2011, 7:11:32 AM8/1/11
to nxt-p...@googlegroups.com
On Sun, Jul 31, 2011 at 05:32:46PM -0700, zbuhman wrote:
> Though I'm not exactly sure what's going on,
> "usb.backend.libusb10:_LibUSB.get_configuration(None)" looks awefully
> suspicious.

We don't even call libusb's get_configuration method. The only thing you
could try to stop that from happening is remove line 46 (a reset() call)
of usbsock.py, which is where it seems to cause the device close/reopen
and get_configuration event.

> http://paste.pocoo.org/show/450231/

I note you're using the 3.0 kernel...could this have something to do
with it, just maybe?

> lejos, which also uses libusb, works just fine for me (so I would
> assume my system is configured correctly).

libusb, but not pyusb. I believe that pyusb is at least part of the
problem here.

--
Marcus Wanner

signature.asc

River

unread,
Aug 24, 2011, 12:40:19 AM8/24/11
to nxt-python
I am having the exact same issue and I am running Ubuntu 10.04. I took
your advice and commented out the reset() in /usr/local/lib/python2.6/
dist-packages/nxt/usbsock.py. It seemed to do the trick.

Thanks.
>  signature.asc
> < 1KViewDownload

Zack Buhman

unread,
Aug 24, 2011, 11:53:58 AM8/24/11
to nxt-p...@googlegroups.com
I will definitely try that next chance I get.

> --
> You received this message because you are subscribed to the Google Groups "nxt-python" group.
> To post to this group, send email to nxt-p...@googlegroups.com.
> To unsubscribe from this group, send email to nxt-python+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nxt-python?hl=en.
>
>

River

unread,
Aug 24, 2011, 2:39:33 PM8/24/11
to nxt-python
Although it did fix that issue, another..."annoyance" popped up as a
result. Because it no longer resets, I found that I must reset the nxt
brick after I run something. I'll try uncommenting out the reset after
the first run later and see if it works or still gives seg fault.
Message has been deleted

River

unread,
Aug 25, 2011, 1:56:21 AM8/25/11
to nxt-python
Although the reset seems to be the cause of the seg fault, the seg
fault actually occurs in locator.py at:

info = b.get_device_info()

which ends up wanting to perform a write in the get_device_info's poll
function. As a result, in the muddle of pyusb it needs the
configuration before writing and attempts to get it, but there isn't
one, so it seg faults.

I think I have found a solution though which works for me. In /usr/
local/lib/python2.6/dist-packages/nxt/usbsock.py add:

self.handle.setConfiguration(1)

after self.handle.reset() (on line 46).

Hopefully, this will work for you as well.
Reply all
Reply to author
Forward
0 new messages