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

[ESP-WIFI] Index out of bounds panic when connecting to enterprise wifi. #2201

Closed
m-dahl opened this issue Sep 20, 2024 · 2 comments · Fixed by #2202
Closed

[ESP-WIFI] Index out of bounds panic when connecting to enterprise wifi. #2201

m-dahl opened this issue Sep 20, 2024 · 2 comments · Fixed by #2202
Assignees
Labels
bug Something isn't working package:esp-wifi Issues related to the esp-wifi package status:needs-attention This should be prioritized
Milestone

Comments

@m-dahl
Copy link

m-dahl commented Sep 20, 2024

Bug description

Hi. Thanks to the work in #2004 we have been able to switch our application from idf to esp-hal + embassy. Its working well but we hit an issue the other day. I have implemented simple roaming by scanning for better access points and disconnect the current one and selecting the one I want by setting a specific BSSID. It works fine, but after a while it panics (details below).

To Reproduce

  1. Connect and disconnect to wifi (enterprise) in a loop.
  2. Panics on the 7th connection attempt.

e.g.

    controller.start().await.expect("wifi: start");
    controller.set_configuration(&client_conf).expect("wifi: set_configuration");
    loop {
        log::info!("CONNECT");
        controller.connect().await;
        Timer::after(Duration::from_millis(1000)).await;

        log::info!("DISCONNECT");
        controller.disconnect().await;
        Timer::after(Duration::from_millis(1000)).await;
    }

Result:

====================== PANIC ======================
panicked at /Users/user/.cargo/git/checkouts/esp-hal-42ec44e8c6943228/5de267a/esp-wifi/src/compat/common.rs:204:24:
index out of bounds: the len is 10 but the index is 10

Backtrace:

0x420233b6
0x420233b6 - esp_wifi::compat::common::create_recursive_mutex::{{closure}}
    at /Users/user/.cargo/git/checkouts/esp-hal-42ec44e8c6943228/5de267a/esp-wifi/src/compat/common.rs:204

It seems MUTEX_IDX_CURRENT is only ever incremented so eventually you go oob. Maybe related to warning warn!("trying to remove a mutex via sem_delete"); which looks like a TODO in common.rs?

Environment

  • esp32c3 + enterprise wifi network
  • esp-hal/wifi latest commit (5de267a).
@m-dahl m-dahl added bug Something isn't working status:needs-attention This should be prioritized labels Sep 20, 2024
@SergioGasquez SergioGasquez added the package:esp-wifi Issues related to the esp-wifi package label Sep 20, 2024
@bjoernQ bjoernQ self-assigned this Sep 20, 2024
@bjoernQ bjoernQ added this to the 0.21.0 milestone Sep 20, 2024
@bjoernQ
Copy link
Contributor

bjoernQ commented Sep 20, 2024

The issue is caused by wpa-supplicant which is really calling sem_delete for a mutex - I have a fix which I will PR soon.

However, while testing it turned out that on ESP32-C3 things still stop working after a few iterations while it works "forever" on other chips. We already discovered unrelated other issues so we need to update the wifi drivers

I will start working on #2154 next, so we can get that fixed

@m-dahl
Copy link
Author

m-dahl commented Sep 20, 2024

Thanks for the quick update! I will follow the progress on #2154 then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package:esp-wifi Issues related to the esp-wifi package status:needs-attention This should be prioritized
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants