-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Deadlock while using wifi routines from the timer task (IDFGH-1143) #3458
Comments
Different scenario, same root cause. Thread 8 (Thread 1073412856): Thread 9 (Thread 1073500544): |
@Sermus, thanks for reporting this bug. We already have solution for it, will merge it once it passes internal code review and testing. |
This issue is fixed in commit: 197e0ae |
@Sermus Thanks for reporting the issue, feel free to reopen the issue if it still exists. Thanks. |
…espressif#3458) * SPI: Fix discarded-qalifiers warning when compiling with all warnings This fixes an error introduced with changeset b847f41 which tightened the use of const for read-only data. The helper funtion __transferBytes also requires the const qualifier on outgoing data. Without this change a warning is displayed when compiling with the Arduino IDE set to display "All" compiler warnings. Tests: - Build an ESP32 SPI sketch that uses static const data to send to an SPI device using the SPI.transferBytes() API * SPI:Ensure all local functions are marked static This audits all functions in the esp32-hal-xpi.c module and ensures that any functions entirely local to the module are marked as static. Tests: - Build with Arduino set to show all warnings and ensure none are displayed * SPI: Remove unused local __spiTranslate24 function This removes the __spiTranslate24() function which is unused.
Environment
git describe --tags
to find it): 3.1.3xtensa-esp32-elf-gcc --version
to find it): 1.22.0-80-g6c4433aProblem Description
There is a deadlock. WiFi and timer tasks fall into a deadlock by cross-acquiring timer protection mutex and a wifi mutex.
The callstacks for the corresponding threads are:
Thread 8 (Thread 1073500392):
#0 0x4008f499 in xQueueGenericReceive (xQueue=0x3ffaea74, pvBuffer=0x0, xTicksToWait=4294967295, xJustPeeking=0) at .../esp-idf/components/freertos/queue.c:1592
#1 0x4008f4f4 in xQueueTakeMutexRecursive (xMutex=0x3ffaea74, xTicksToWait=4294967295) at .../esp-idf/components/freertos/queue.c:635
#2 0x400d20b5 in esp_timer_delete (timer=0x3ffce4ac) at .../esp-idf/components/esp32/esp_timer.c:166
#3 0x400fb42e in ets_timer_done (ptimer=0x3ffbb0d4) at .../esp-idf/components/esp32/ets_timer_legacy.c:97
#4 0x400fb1c0 in timer_done_wrapper (ptimer=0x3ffbb0d4) at .../esp-idf/components/esp32/esp_adapter.c:350
#5 0x4010d03d in ieee80211_mlme_connect_bss ()
#6 0x40113d47 in ?? ()
#7 0x40114213 in ?? ()
#8 0x40114c94 in cnx_csa_fn_process ()
#9 0x40112f8b in ?? ()
#10 0x40113101 in ieee80211_timer_do_process ()
#11 0x4008da6b in ppTask ()
#12 0x4008eb49 in vPortTaskWrapper (pxCode=0x4008d9ac , pvParameters=0x0) at .../esp-idf/components/freertos/port.c:143
Thread 7 (Thread 1073412812):
#0 0x4008f499 in xQueueGenericReceive (xQueue=0x3ffc5250, pvBuffer=0x0, xTicksToWait=4294967295, xJustPeeking=0) at .../esp-idf/components/freertos/queue.c:1592
#1 0x400fb278 in semphr_take_wrapper (semphr=0x3ffc5250, block_time_tick=4294967295) at .../esp-idf/components/esp32/esp_adapter.c:234
#2 0x40108538 in ieee80211_ioctl ()
#3 0x400fcca2 in esp_wifi_sta_get_ap_info ()
#4 0x400ebcc9 in network::update_network_info (arg=) at .../board/src/commons/net/network/network.cpp:304
#5 0x400d1fbf in timer_process_alarm (dispatch_method=) at .../esp-idf/components/esp32/esp_timer.c:290
#6 0x400d2052 in timer_task (arg=0x0) at .../esp-idf/components/esp32/esp_timer.c:318
#7 0x4008eb49 in vPortTaskWrapper (pxCode=0x400d2034 <timer_task>, pvParameters=0x0) at .../esp-idf/components/freertos/port.c:143
The deadlock is induced by esp_wifi_sta_get_ap_info being called from the timer thread which is done within a scope protected by mutex 0x3ffaea74 because this is done in timer callback context. While executing esp_wifi_sta_get_ap_info it obviously tries to acquire semaphore 0x3ffc5250 which is supposedly already taken by the WiFi thread. The latter one at this moment tries to capture mutex 0x3ffaea74 during the timer delete routine. Finita...
Steps to repropduce
They are obvious from the callstacks.
Code to reproduce this issue
Invoke esp_wifi_sta_get_ap_info (or another wifi-related stuff) in timer thread. Repro rate is not 100%, but the symptoms are clear from the callstacks and analysis above.
The text was updated successfully, but these errors were encountered: