Re: [Libusbx-devel] [libusbx] Core: libusb_interrupt_transfer and libusb_control_transfer does not return in case of error (#76)

2014-01-10 Thread Hans de Goede
An EFAULT error indicates we've have bad pointers and are writing / reading random memory at that point all bets are off. If you can show me a real-world example where we get another error then EFAULT and go into an infinite loop, then I'm interested in fixing that. For the EFAULT problem you

Re: [Libusbx-devel] [libusbx] Core: libusb_interrupt_transfer and libusb_control_transfer does not return in case of error (#76)

2014-01-09 Thread Hans de Goede
miguelfreitas, please stop trying to somehow propagate the EFAULT and recover from it. Something is causing bad pointers and/or memory corruption, once that happens any predictable behavior is off the table. I will only accept a patch for this if it turns out the bad pointers are caused by a

Re: [Libusbx-devel] [libusbx] Core: libusb_interrupt_transfer and libusb_control_transfer does not return in case of error (#76)

2014-01-09 Thread Orin Eman
If an EFAULT return from the kernel results in an infinite loop in libusb(x): It's not a matter of _recovering_ from the EFAULT. It's a matter of whether libusb(x) should propagate it to the caller or not. There is simply _no_ excuse not to propagate it. Sarcasm on Should we tell the kernel

Re: [Libusbx-devel] [libusbx] Core: libusb_interrupt_transfer and libusb_control_transfer does not return in case of error (#76)

2014-01-07 Thread miguelfreitas
I chose not to use memmove but rather read and write all buffer bytes in a loop (not sure if memmove would optimize src==dst case). I could successfully trigger the EFAULT and it did not cause any segfault. patch (just for reference): https://gist.github.com/miguelfreitas/8298825 besides i

Re: [Libusbx-devel] [libusbx] Core: libusb_interrupt_transfer and libusb_control_transfer does not return in case of error (#76)

2014-01-07 Thread miguelfreitas
@jwrdegoede I have read the processcompl() you mention and i agree the only failure case is when one of the put_user or copy_to_user fails. -EFAULT is the only error code used there. Another raw guess: is it possible that data was corrupted during USB transfer (this actually happens here due

Re: [Libusbx-devel] [libusbx] Core: libusb_interrupt_transfer and libusb_control_transfer does not return in case of error (#76)

2014-01-06 Thread miguelfreitas
@jwrdegoede here is what happens with current master: ``` libusbx: error [reap_for_handle] reap failed error -1 errno=14 libusbx: error [handle_events] backend handle_events failed with error -1 libusbx: error [sync_transfer_wait_for_completion] libusb_handle_events failed: LIBUSB_ERROR_IO,

Re: [Libusbx-devel] [libusbx] Core: libusb_interrupt_transfer and libusb_control_transfer does not return in case of error (#76)

2014-01-06 Thread miguelfreitas
@jwrdegoede you are right about the previous patch being incorrect as you pointed here: http://sourceforge.net/mailarchive/message.php?msg_id=31068411 I have just tried exiting the while when libusb_cancel_transfer() != 0. As you predicted, we can't use libusb_free_transfer() because it will

Re: [Libusbx-devel] [libusbx] Core: libusb_interrupt_transfer and libusb_control_transfer does not return in case of error (#76)

2014-01-06 Thread Hans de Goede
sigh. listen the EFAULT error is being thrown by this bit of code inside libusb: static int reap_for_handle(struct libusb_device_handle *handle) { struct usbfs_urb *urb; int r = ioctl(hpriv-fd, IOCTL_USBFS_REAPURBNDELAY, urb); if (r 0) { Notice how the only address