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

Check for event queue overflow in usbd / dcd_event_handler #1662

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

Erlkoenig90
Copy link

When using osal_queue_send to send events to the queue _usbd_q in udbd.c's dcd_event_handler, the queue may overflow (particularly if the application calls usbd_defer_func too often). In that case, events will be missed, leading to spurious and hard-to-debug errors (for example, IN data is sent, ISR is called, but nothing else happens).

Therefore I'd like to suggest adding TU_ASSERT around the calls to osal_queue_send in order to make finding these bugs easier.

@hathach
Copy link
Owner

hathach commented Jan 7, 2023

which RTOS you are using, the osal_none does have an TU_ASSERT() when adding item to queue.

@Erlkoenig90
Copy link
Author

I'm using FreeRTOS, via ESP-IDF. What's the point of the return value in osal_queue_send if there is a TU_ASSERT, i.e. the return value is supped to be always true?

@hathach hathach force-pushed the check-usbd-queue-overflow branch from 6a18de0 to 189080b Compare April 16, 2024 03:40
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the Pr, and sorry for late response. I have rebased and add check for queuing new usb event

@hathach hathach merged commit f3781a4 into hathach:master Apr 16, 2024
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants