AristoChen / usb-proxy

A USB proxy based on raw-gadget and libusb
Apache License 2.0
161 stars 30 forks source link

Interrupted system call #25

Open rlewkowicz opened 2 months ago

rlewkowicz commented 2 months ago

I'm trying to sniff a handshake between an xbox series x and its controller. I'm sure I'll run into issues after this, but I think it's not terming correctly?

https://github.com/AristoChen/usb-proxy/blob/c6454cec6563185a43cd6d59bb967da555b89081/proxy.cpp#L350

Here you kill the threads, but here it exits the application with usb_raw_ep_read(): Interrupted system call

https://github.com/AristoChen/usb-proxy/blob/c6454cec6563185a43cd6d59bb967da555b89081/proxy.cpp#L254

xairy commented 2 months ago

Please try this patch:

diff --git a/proxy.cpp b/proxy.cpp
index beefeb2..b28b726 100644
--- a/proxy.cpp
+++ b/proxy.cpp
@@ -249,6 +249,11 @@ void *ep_loop_read(void *arg) {
                                        ep.bEndpointAddress, transfer_type.c_str(), dir.c_str());
                                break;
                        }
+                       if (rv < 0 && errno == EINTR) {
+                               printf("EP%x(%s_%s): interface likely changing, stopping thread\n",
+                                       ep.bEndpointAddress, transfer_type.c_str(), dir.c_str());
+                               break;
+                       }
                        else if (rv < 0) {
                                perror("usb_raw_ep_read()");
                                exit(EXIT_FAILURE);
rlewkowicz commented 2 months ago

I did something similar. I'm doing so many devices right now so I lose tack of what errors I got where. Ultimately something strange is going on with iSync transfer. I straight up pass the read threads on iSync and it keeps running otherwise it segfaults.

It starts ep5 (which I'm sure is different device to device), passes flag of 0 and gets invalid Args. I know there's issues for isync.

I'm getting heavy into a lot of this stuff. My cynthion from great Scott just arrived, I'll play with it a bit and come back to this.

AristoChen commented 1 month ago

Hi @rlewkowicz

thanks for reporting the issue, do you have any chance to see if the PR #26 (Thanks @xairy !) fixes the issue?

thanks!