nxdk-sdl icon indicating copy to clipboard operation
nxdk-sdl copied to clipboard

SDL does not call ``usbh_core_deinit()`` on exit

Open LoveMHz opened this issue 1 year ago • 1 comments

In its current implementation, SDL does not call usbh_core_deinit() on exit.

When software exits, or when an XBE is launched, the system performs a soft reset, but the kernel has no mechanisms, to my knowledge, that would reset the USB hardware (all retail software attempts to uninitialize previously initialized hardware on exit).

This leaves a brief amount of time where, from soft-reset to the next application re-initializing the USB stack, that memory corruption can occur due to the USB hardware now pointing to an invalid region of memory.

I understand that as implemented, it's implied that it's up to the application to call usbh_core_deinit(). Ref

I'm opening this issue because I can not find any proof that software is currently doing this, and I believe it is an anti-pattern to the design and implementation goals of SDL.

I believe we need to handle this better, and I'm open to discussing what would be the better implementation. Right now, I'm investigating any possible side effects that may arise from this type of change.

LoveMHz avatar Jun 25 '23 17:06 LoveMHz