Skip to content

zephyr-cp: common_hal_wifi_scannednetworks_next() waits on k_poll(K_FOREVER) with no bound (no reproducible hang) #59

Description

@mikeysklar

Recovering from #58 by calling wifi.radio.stop_scanning_networks() hung the board hard.

Observed

Board associated, web workflow serving, radio stuck in the #58 state. Ran:

import wifi
r = wifi.radio
r.stop_scanning_networks()

After that:

  • no serial output at all on the console UART
  • web workflow gone, curl http://<ip>/cp/version.json returns nothing (curl exit 000)
  • the J-Link still enumerates and commander adapter list still reports the board

Only commander device reset recovered it, about 19 seconds to come back.

Note

common_hal_wifi_radio_stop_scanning_networks() already carries this comment at Radio.c:272:

// Return early if self->current_scan is NULL to avoid hang
if (self->current_scan == NULL) {
    return;
}

So a hang in this function is already known, and the existing guard only covers the NULL case. Here current_scan was non-NULL but pointed at a scan that had been abandoned, and wifi_scannednetworks_deinit() was reached with the msgq, fifo and k_poll state left mid-scan.

I have not isolated which part of wifi_scannednetworks_deinit() blocks. Worth checking whether it waits on channel_done or drains the fifo without a timeout when no further scan results will ever arrive.

This matters more than the scan duplication in #57: it takes the whole board down, including the network stack, from ordinary Python.

Related: #58, #57.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions