max3421 (ESP): the task-context interrupt handler can take mutexes hcd_deinit() deleted
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 28/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- embedded-iot
Direzione di ricerca
Start by reading hcd_deinit() in src/portable/analog/max3421/hcd_max3421.c:571-589 alongside max3421_intr_task() in hw/bsp/espressif/boards/family.c:230-237, then trace where max3421_intr_sem is given and where the GPIO interrupt is disabled. The fix either stops and drains the task before the mutexes are deleted, or has the handler check a cleared running flag before locking; note osal_mutex_lock under FreeRTOS is xSemaphoreTake in src/osal/osal_freertos.h:224-226. Done means tuh_deinit() with a device mounted no longer reaches a NULL mutex, validated on a dual-core ESP32 with a MAX3421 attached.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Found while reviewing https://github.com/hathach/tinyusb/pull/4619 at 9b6be7461; outside that PR's scope. Source
trace by review, not reproduced on hardware.
Problem
hcd_deinit() (src/portable/analog/max3421/hcd_max3421.c:571-589) deletes spi_mutex and handler_mutex and sets
both to NULL. On Espressif the MAX3421 interrupt is serviced from a task: max3421_intr_task()
(hw/bsp/espressif/boards/family.c:230-237) loops on max3421_intr_sem and calls
tuh_int_handler(BOARD_TUH_RHPORT, false). Nothing stops or drains that task before the mutexes are deleted.
Two ways the handler runs after deletion:
- the semaphore was given before
tuh_max3421_int_api(rhport, false)disabled the GPIO interrupt, so the task wakes
afterhcd_deinit()returned; - on a dual-core ESP32 the task runs on the other core while
hcd_deinit()executes. With a device attached, FRAME
IRQs fire every 1 ms, so the window is not narrow.
The handler then calls osal_mutex_lock(NULL, ...), which is xSemaphoreTake(NULL) (src/osal/osal_freertos.h:224-226):
an assert or crash during teardown.
handler_mutex was added by #4619; spi_mutex is deleted the same way on master 1384420308, so the hazard predates
it.
Not affected
- usbh itself makes no HCD transfer call after
hcd_deinit():usbh_task_run()returns when!tuh_inited()
(src/host/usbh.c:869-871). - No in-tree example calls
tuh_deinit()on a MAX3421 build, so nothing in the tree triggers it today.
Severity: low.
Related: #4489 A3 — tuh_deinit() order of hcd_deinit() against the device-tree teardown; that is the usbh side, this
one is the ESP BSP's handler task.
Remaining work
In the ESP BSP, stop and drain max3421_intr_task before hcd_deinit() deletes the mutexes, or have the handler bail
out on a cleared running flag before locking. Validate on an ESP32 dual-core board with MAX3421 attached by calling
tuh_deinit() with a device mounted.
Why deferred
Lifecycle of a BSP task with no in-tree caller of tuh_deinit() on this configuration; it belongs in its own change
with hardware validation, not in #4619's device-removal handling.
- Lingua principale
- C
- Stelle
- 7.3k
- Fork
- 1.6k
- Merge medio
- 1g 19h
- PR unite (30g)
- 67
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hathach/tinyusb
-
follow-up Port WCH USBFS Prio 📌
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
follow-up Prio 📌
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
hil-contract: a background hil_remote.py launch is killed at the Bash default 10 min timeoutForse già presa @hathach l’ha presa 16 giorni fa. Apertafollow-up Prio 📌
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
ch32v30x: debug UART loses queued bytes when its TX ring fillsForse già presa @hathach l’ha presa 16 giorni fa. Apertafollow-up Prio 📌
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
followup Prio 📌
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di hathach/tinyusb
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
rofl0r/proxychains-ng#631 ·
-
RP2350: enabling secure boot via rescue fails with 6400 (BOOTKEY written as 33 bytes in ECC mode)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
pcqpcq/open-source-android-apps#619 ·
I maintainer di solito rispondono entro 1 giorno
-
Can't link with minizip-ngAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
-
Missing slice offset check in jvp_equal fast path corrupts slice comparison and aborts delpathsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni