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

WiFiClient::flush() crashes due to Load Prohibit since 2.0.12, earlier versions work fine. #8681

Closed
1 task done
fredlcore opened this issue Sep 29, 2023 · 15 comments · Fixed by #8699
Closed
1 task done
Labels
Priority: High 🗻 Issues with high priority which needs to be solved first. Status: Solved Type: Bug 🐛 All bugs Type: Regression Result of unforeseen consequences of a previous change

Comments

@fredlcore
Copy link

Board

ESP32 Olimex EVB and other ESP32 boards

Device Description

None.

Hardware Configuration

Nothing

Version

v2.0.13

IDE Name

Arduino IDE 2.2.1

Operating System

MacOS Sonoma

Flash frequency

80 MHz

PSRAM enabled

yes

Upload speed

115200

Description

This change leads to a Guru meditation due to Load Prohibited when calling client.flush() on a WiFiClient instance:

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400e3847  PS      : 0x00060f30  A0      : 0x800e3950  A1      : 0x3ffb1f50  
A2      : 0x00000000  A3      : 0x3ffbfd38  A4      : 0x00000384  A5      : 0x00000001  
A6      : 0x000000ff  A7      : 0x3f4059d4  A8      : 0x8008fccc  A9      : 0x3ffb1f40  
A10     : 0x00000001  A11     : 0x0002710d  A12     : 0x00027385  A13     : 0x00060f23  
A14     : 0x00060f20  A15     : 0x00000001  SAR     : 0x0000000c  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000010  LBEG    : 0x4008ad85  LEND    : 0x4008ad95  LCOUNT  : 0xfffffff5  
Backtrace: 0x400e3844:0x3ffb1f50 0x400e394d:0x3ffb1f80 0x400dc1fd:0x3ffb1fa0 0x400ee93d:0x3ffb2290
ELF file SHA256: 4726c43adf41a5ad

ESP Stack Trace decoder gives me this:

PC: 0x400e387f: WiFiClientRxBuffer::r_available() at /Users/frederik/Library/Arduino15/packages/esp32/hardware/esp32/2.0.13/libraries/WiFi/src/WiFiClient.cpp line 46
EXCVADDR: 0x00000010

Decoding stack results
0x400e387c: WiFiClientRxBuffer::r_available() at /Users/frederik/Library/Arduino15/packages/esp32/hardware/esp32/2.0.13/libraries/WiFi/src/WiFiClient.cpp line 44
0x400e3985: WiFiClient::flush() at /Users/frederik/Library/Arduino15/packages/esp32/hardware/esp32/2.0.13/libraries/WiFi/src/WiFiClient.cpp line 158
0x400df411: loop() at /Users/frederik/Downloads/BSB-LAN-master/BSB_LAN/BSB_LAN.ino line 7073
0x400ee1f5: loopTask(void*) at /Users/frederik/Library/Arduino15/packages/esp32/hardware/esp32/2.0.13/cores/esp32/main.cpp line 50

The trace narrows the culprit down to line 46:

if(_fd < 0){

If I do a Serial.println(_fd); right before that, the ESP32 crashes.
It seems not to happen all the time, but the reason either seems to be if there are still characters in the incoming client buffer (for lack of a better word) or if there are no more characters coming in.
This problem only occurs in 2.0.12 and 2.0.13, once I revert back to 2.0.11 the problem is gone.
Can you please investigate this further and if possible revert to the state from 2.0.11?
Thank you!

Sketch

client.flush();

Debug Message

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400e3847  PS      : 0x00060f30  A0      : 0x800e3950  A1      : 0x3ffb1f50  
A2      : 0x00000000  A3      : 0x3ffbfd38  A4      : 0x00000384  A5      : 0x00000001  
A6      : 0x000000ff  A7      : 0x3f4059d4  A8      : 0x8008fccc  A9      : 0x3ffb1f40  
A10     : 0x00000001  A11     : 0x0002710d  A12     : 0x00027385  A13     : 0x00060f23  
A14     : 0x00060f20  A15     : 0x00000001  SAR     : 0x0000000c  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000010  LBEG    : 0x4008ad85  LEND    : 0x4008ad95  LCOUNT  : 0xfffffff5  
Backtrace: 0x400e3844:0x3ffb1f50 0x400e394d:0x3ffb1f80 0x400dc1fd:0x3ffb1fa0 0x400ee93d:0x3ffb2290
ELF file SHA256: 4726c43adf41a5ad

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@fredlcore fredlcore added the Status: Awaiting triage Issue is waiting for triage label Sep 29, 2023
@lucasssvaz
Copy link
Collaborator

Could you please provide a sample sketch that causes this error ?

@fredlcore
Copy link
Author

fredlcore commented Oct 2, 2023

Here's a minimalistic reduced version:

#include <Arduino.h>
#include <WiFi.h>
#include <Ethernet.h>

EthernetClient client1;
WiFiClient client2;

void loop() {
  delay(1);
  Serial.print(".");
}

void setup() {
  Serial.begin(115200);
  Serial.println("READY");
  Serial.println("Flush EthernetClient client...");
  client1.flush();
  delay(5000);
  Serial.println("Flush WiFiClient client...");
  client2.flush();
  delay(5000);
  Serial.println("Setup complete");
}

You can see that client1.flush() (EthernetClient) goes through, client2.flush() (WiFiClient) crashes with 2.0.13. If you revert back to 2.0.11 or earlier, both work fine.

@Jason2866 Jason2866 added Type: Bug 🐛 All bugs Type: Regression Result of unforeseen consequences of a previous change Priority: High 🗻 Issues with high priority which needs to be solved first. and removed Status: Awaiting triage Issue is waiting for triage labels Oct 2, 2023
@Jason2866
Copy link
Collaborator

Jason2866 commented Oct 2, 2023

@me-no-dev @PilnyTomas Please take a look. We run in this issue with Tasmota too. Older core does work as for @fredlcore
Probably caused from #8541

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x40115c31  PS      : 0x00060130  A0      : 0x801637df  A1      : 0x3ffd1de0  
=> 0x40115c31: WiFiClientRxBuffer::r_available() at /Users/x/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiClient.cpp:51
      (inlined by) WiFiClientRxBuffer::flush() at /Users/x/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiClient.cpp:163
      (inlined by) WiFiClient::flush() at /Users/x/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiClient.cpp:539
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x3f40e188  A5      : 0x3ffd1ea0  
A6      : 0x00ff0000  A7      : 0xff000000  A8      : 0x00001388  A9      : 0x00000009  
A10     : 0x3f422bc8  A11     : 0x3f423428  A12     : 0x3ffd1e18  A13     : 0x00000000  
A14     : 0x00000014  A15     : 0x40404040  SAR     : 0x0000000a  EXCCAUSE: 0x0000001c  
=> 0x40404040: ?? ??:0
EXCVADDR: 0x00000010  LBEG    : 0x40095275  LEND    : 0x40095299  LCOUNT  : 0x800dfa65  
=> 0x40095275: strcmp at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strcmp.S:586
=> 0x40095299: strcmp at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strcmp.S:604


Backtrace: 0x40115c2e:0x3ffd1de0 0x401637dc:0x3ffd1e10 

Tried with Arduino 3.0 too (code is same). Crash happens on same place (stace track looks same)

@Jason2866
Copy link
Collaborator

Reverting does solve. Checked with this sketch

#include <Arduino.h>
#include <WiFi.h>

WiFiClient client;

void loop() {
  delay(1);
  Serial.print(".");
}

void setup() {
  Serial.begin(115200);
  Serial.println("READY");
  delay(1000);
  Serial.println("Flush WiFiClient client...");
  client.flush();
  delay(2000);
  Serial.println("Setup complete");
}

@Jason2866
Copy link
Collaborator

@lucasssvaz Solved? The reason is found for the issue. Not solved. Should i open a revert PR?

@lucasssvaz
Copy link
Collaborator

Ah, I thought that PR was in this repo as it had the same name, my bad 😓. Yes, please open a revert PR as this won't break anything.

@fredlcore
Copy link
Author

Will this then "heal" 2.0.13 or will this lead to a 2.0.14 - and if so, when?

@lucasssvaz
Copy link
Collaborator

As this affects the WiFi it will probably lead to version 2.0.14 ASAP

@lucasssvaz
Copy link
Collaborator

@me-no-dev @SuGlider Should we fix this in 3.0.0 or create a 2.0.14 release ?

@fredlcore
Copy link
Author

Please don't wait until 3.0.0 - Our project has several hundred installs and when the users install the next update, it will crash all the time, unless I remove all client.flush() instances.

@SuGlider
Copy link
Collaborator

SuGlider commented Oct 3, 2023

@me-no-dev @SuGlider Should we fix this in 3.0.0 or create a 2.0.14 release ?

I think that we should target 3.0.0.

@fredlcore
Copy link
Author

May I ask why? 2.0.12 and 2.0.13 have been released relatively shortly after one another, partly because of bug fixes, so what is different here?

@lucasssvaz
Copy link
Collaborator

I've just submitted a patch to fix it. 2.0.14 should be released soon including it.

@Jason2866
Copy link
Collaborator

Jason2866 commented Oct 4, 2023

@lucasssvaz CI fails, ahh it is fixed now.

@lucasssvaz
Copy link
Collaborator

It was just a reorder warning. I forgot to enable my compilation warnings locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High 🗻 Issues with high priority which needs to be solved first. Status: Solved Type: Bug 🐛 All bugs Type: Regression Result of unforeseen consequences of a previous change
Projects
None yet
4 participants