CORRUPT HEAP in WiFi mode WIFI_MODE_APSTA

marclee
Posts: 51
Joined: Fri Apr 09, 2021 1:09 pm

CORRUPT HEAP in WiFi mode WIFI_MODE_APSTA

Postby marclee » Thu Nov 24, 2022 2:51 pm

I'm posting this problem in a new post, even I think it could be related to the problem I posted some weeks ago: viewtopic.php?f=13&t=30038

Configuration:
* ESP-IDF v5.0-rc1
* ESP32-C3
* Heap debugging is activated in comprehensive mode.
* WiFi is in mode WIFI_MODE_APSTA
* Scan is running in background (esp_wifi_scan_start).

Now an external device tries to connect to ESP32-C3 (AP mode).

  1. !!!!!! wifi_event_handler: event_base = 87, event_id = WIFI_EVENT_AP_START !!!!!!
  2. !!!!!! heap_caps_check_integrity_all = 1 !!!!!!
  3.  
  4. I (763) wifi:Set ps type: 1
  5. I (763) wifi:Set ps type: 0
  6. I (763) dns_server: Socket created
  7. I (773) dns_server: Socket bound, port 53
  8. I (773) dns_server: Waiting for data
  9. I (3403) wifi:new:<2,1>, old:<2,1>, ap:<2,1>, sta:<0,0>, prof:2
  10. I (3403) wifi:station: xx:xx:xx:xx:xx:xx join, AID=1, bgn, 40U
  11.  
  12. !!!!!! wifi_event_handler: event_base = 87, event_id = WIFI_EVENT_AP_STACONNECTED !!!!!!
  13. !!!!!! heap_caps_check_integrity_all = 1 !!!!!!
  14.  
  15. I (3553) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.4.2
  16. I (5573) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.4.2
  17. I (12033) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.4.2
  18.  
  19. !!!!!! wifi_event_handler: event_base = 87, event_id = WIFI_EVENT_AP_STADISCONNECTED !!!!!!
  20. !!!!!! heap_caps_check_integrity_all = 1 !!!!!!
  21.  
  22. W (39333) wifi:Haven't to connect to a suitable AP now!
  23. I (39333) wifi:new:<2,1>, old:<2,1>, ap:<2,1>, sta:<0,0>, prof:2
  24. I (39533) wifi:Send SA Query req with transaction id 5e01
  25. I (39743) wifi:Send SA Query req with transaction id f227
  26. I (39943) wifi:Send SA Query req with transaction id a77a
  27. I (40153) wifi:Send SA Query req with transaction id aaf8
  28. I (40353) wifi:Send SA Query req with transaction id d7b4
  29. I (40563) wifi:STA not responded to 5 SA Query attempts, Reset connection sending disassoc
  30.  
  31. I (40563) wifi:station: xx:xx:xx:xx:xx:xx leave, AID = 1, bss_flags is 658547, bss:0x3fcb1998
  32. I (40563) wifi:new:<2,0>, old:<2,1>, ap:<2,1>, sta:<0,0>, prof:2
  33.  
  34. !!!!!! wifi_event_handler: event_base = 87, event_id = WIFI_EVENT_AP_STADISCONNECTED !!!!!!
  35. CORRUPT HEAP: Invalid data at 0x3fcb1c98. Expected 0xfefefefe got 0x00000000
  36. !!!!!! heap_caps_check_integrity_all = 0 !!!!!!
  37.  
  38. W (40593) wifi:Haven't to connect to a suitable AP now!
  39. I (40903) wifi:new:<2,1>, old:<2,0>, ap:<2,1>, sta:<0,0>, prof:2
  40. I (40903) wifi:station: xx:xx:xx:xx:xx:xx join, AID=1, bgn, 40U
  41. CORRUPT HEAP: Invalid data at 0x3fcb1c98. Expected 0xfefefefe got 0x00000000
  42.  
  43. assert failed: multi_heap_malloc multi_heap_poisoning.c:256 (ret)
  44. Stack dump detected
  45.  
  46. MEPC    : 0x40380922  RA      : 0x40388254  SP      : 0x3fca42d0  GP      : 0x3fc91a00  
  47. 0x40380922: panic_abort at /home/marc/esp/esp-idf_v5.0-rc1/components/esp_system/panic.c:412
  48. 0x40388254: __ubsan_include at /home/marc/esp/esp-idf_v5.0-rc1/components/esp_system/ubsan.c:313

This error occurs many times but not every time.

I'm wondering why after connecting (event = WIFI_EVENT_AP_STACONNECTED) the event WIFI_EVENT_AP_STADISCONNECTED occurs twice.

The first time, WIFI_EVENT_AP_STACONNECTED occurs, heap_caps_check_integrity_all returns 1 = no error.
The second time, WIFI_EVENT_AP_STACONNECTED occurs, heap_caps_check_integrity_all returns 0 = error.

Between heap_caps_check_integrity_all = 1 and heap_caps_check_integrity_all = 0 no custom code is executed. So I guess the bug can't be within custom code. Am I right?

Sometimes the error occurs if connection has succeeded, after scan has finished.

It looks like scanning while ESP32-C3 is connected in AP mode, doesn't work properly in this case.

Connecting in STA mode works without any problems (AP disconnected).

If heap debugging is in no poisoning mode, no error occurs.

Who is online

Users browsing this forum: Baidu [Spider] and 258 guests