Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

probe: block signals around USB transfers #1392

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

flit
Copy link
Member

@flit flit commented May 15, 2022

This patch blocks all signals from being sent to the current thread before performing any USB transfer through pyusb.
For the separate receive threads created by some CMSIS-DAP USB backends, signals are permanently blocked.

The main reason to do this is that a SIGINT can cause a KeyboardInterrupt exception to be raised in the middle of pyusb and/or pyocd USB protocol related code. On occasion, this will cause the protocol to become out of sequence, resulting in all future transfers failing wildly.

@flit flit changed the base branch from main to develop May 15, 2022 21:39
@flit
Copy link
Member Author

flit commented May 22, 2022

Going to pause this one. More work is needed. A KeyboardInterrupt could still be raised from within (for instance) the CMSIS-DAP internal packet management code, which can break the sequencing of protocol transfer commands.

A real question is whether pyocd should even be doing this. Really the application should install its own SIGINT handler that completely avoids using KeyboardInterrupt (which pyocd does not do for its own gdb server, etc, right now!). Perhaps pyocd should just provide a utility to make this easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant