Skip to content

"Guru Meditation Er" - related to http request? #5233

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

Closed
Alexander96f opened this issue Jun 1, 2021 · 9 comments
Closed

"Guru Meditation Er" - related to http request? #5233

Alexander96f opened this issue Jun 1, 2021 · 9 comments
Labels
Area: BT&Wifi BT & Wifi related issues Resolution: Expired More info wasn't provided

Comments

@Alexander96f
Copy link

Hello folks I am currently trying to develop a wifi RFID module based on an ESP32.
Currently I am using a ESP32 Devkit to test the software. I only make a http request like every 200ms to a wifi relais to check the status if its powered on or not.
After some time like 50 minutes the ESP32 just crashes (LED's on the GIPO pins go off) and the programm just stops.

The problem is I dont get a error message which I could decompile, the last stuff I can read in the Serial Monitor is:
"Guru Meditation" or somtimes "Guru Meditation Er"

I first thought that its a problem of the power supply of the ESP32 but I cant reproduce this failure on high power spikes (for example when I put a Chipcard on the RFID module) it just randomly crashes after some time.
The programm probably crashes at the line "if (http.connected()) http.end();"

Does anybody of you has an idea what I can do to locate the exact problem?

Hardware:

Board: ESP32 Dev Module
Core Installation version: I dont know
IDE name: Arduino IDE?
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 512000
Computer OS: Windows 10

Description:

Describe your problem here

Sketch: (leave the backquotes for code formatting)

//Change the code below by your sketch
#include <Arduino.h>
#include <SPI.h>
#include <MFRC522.h>
#include <WiFi.h>
#include <HTTPClient.h>

//Basicly its this part of the code that is from interest I think:

void ShellyAbfragen(){
     if(WiFi.status() != WL_CONNECTED)connectWifi();
      
      // Send HTTP GET request
      http.begin(shelly);
      int httpResponseCode = http.GET();
      
      if (httpResponseCode>0) {
        Serial.print("HTTP Response code: ");
        Serial.println(httpResponseCode);
        String payload = http.getString();
        Serial.println(payload);
        Serial.println("Verbindnung mit Shelly erfolgreich!");
      }
      else {
        Serial.print("Error code: ");
        Serial.println(httpResponseCode);
      }
      // Free resources
      if (http.connected()) http.end();
      //http.end();
}

@lbernstone
Copy link
Contributor

Most likely you have a memory leak. Put this at the top of your code and then call MEMCK; in your loop function.

const char* fmtMemCk = "Free: %d\tMaxAlloc: %d\t PSFree: %d\n";
#define MEMCK Serial.printf(fmtMemCk,ESP.getFreeHeap(),ESP.getMaxAllocHeap(),ESP.getFreePsram())

@Alexander96f
Copy link
Author

Most likely you have a memory leak. Put this at the top of your code and then call MEMCK; in your loop function.

const char* fmtMemCk = "Free: %d\tMaxAlloc: %d\t PSFree: %d\n";
#define MEMCK Serial.printf(fmtMemCk,ESP.getFreeHeap(),ESP.getMaxAllocHeap(),ESP.getFreePsram())

20:40:31.294 -> Free: 280424 MaxAlloc: 113792 PSFree: 0
20:40:31.341 -> running
20:40:31.480 -> HTTP Response code: 200
20:40:31.528 -> {"ison":false,"has_timer":false,"timer_started":0,"timer_duration":0,"timer_remaining":0,"overpower":false,"source":"input"}
20:40:31.622 -> Verbindnung mit Shelly erfolgreich!
20:40:31.669 -> Guru Meditation E

Doesnt look like a memory leak since the free memory was constant on 280424.

do you have some other idea?

@lbernstone
Copy link
Contributor

Put the MEMCK wherever you are passing around String objects between functions or allocating large arrays. This is a problem in your code. You are going to have to troubleshoot it.

@Alexander96f
Copy link
Author

Alexander96f commented Jun 2, 2021

Put the MEMCK wherever you are passing around String objects between functions or allocating large arrays. This is a problem in your code. You are going to have to troubleshoot it.

I allready did as I mentionend in the last comment or do I understand you wrong?
The free memory was constant and then it suddenly crashed.

I uploaded the Code with "Core Debug level: Debug" activated and now the Code is running fine for like 10 hours, even tho I cant read the http request in the serial monitor.

I tried to locate the error, when I put a delay before the http.end(); line I am able to read the full error message.
I used the decoder to to decode the Guru Meditation error:

`PC: 0x40161c7c: HTTPClient::connected() at C:\Users\afahl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\libraries\HTTPClient\src\HTTPClient.cpp line 406
EXCVADDR: 0x0000001a

Decoding stack results
0x40161c7c: HTTPClient::connected() at C:\Users\afahl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\libraries\HTTPClient\src\HTTPClient.cpp line 406
0x400d1283: ShellyAbfragen() at C:\Users\afahl\Desktop\Testprogramme\ESP32 - Lesegerät\ESP32_-Leseger_t/ESP32-Leseger_t.ino line 149
0x400d13d4: loop() at C:\Users\afahl\Desktop\Testprogramme\ESP32 - Lesegerät\ESP32
-Leseger_t/ESP32-_Leseger_t.ino line 123
0x400d7c9d: loopTask(void*) at C:\Users\afahl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32\main.cpp line 37
0x40089872: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
`
But I still dont really know what exactly causes this problem.

best regards
Alexander

@Alexander96f
Copy link
Author

Alexander96f commented Jun 2, 2021

Okay so I digged a little bit deeper:
(Im not that good in programming and debugging so I hope I understand this error right)

The ESP32 crashes when trying to check:
if (http.connected()) http.end();

which refers to the HTTPClient.cpp line 406 which is:
return ((_client->available() > 0) || _client->connected());

Becuse the client object seems to be a null pointer? (0x0000001a?)

To be honest I have no idea how to fix this.

I think my problem is related to #3659

I think I fixed my problem by using this workaround posted in #3659
I hope it also works over time.
I initalized:
WifiClient client;

and changed
http.begin(shelly);
to:
http.begin(client, shelly);

quote from #3659

`Hi, was having the same exception issues and managed to solve it by using a different begin function:

const char *_url = "http://192.168.1.1/getstuff";
WiFiClient client;
HTTPClient http;
http.begin(client,_url);

if( http.GET() )
{
String payload = http.getString();
Serial.println(payload);
payload = String();
}
http.end();`

I still have no idea whats going on.

@VojtechBartoska VojtechBartoska added the Area: BT&Wifi BT & Wifi related issues label Jun 7, 2021
@ppescher
Copy link
Contributor

It looks like it could be related...
Did you try the patch I submitted there?
Or see the merge commit #5197

@stale
Copy link

stale bot commented Sep 19, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Sep 19, 2021
@VojtechBartoska
Copy link
Contributor

Hello @Magerquark, still relevant? Thanks for your answer!

@VojtechBartoska VojtechBartoska added Resolution: Awaiting response Waiting for response of author and removed Status: Stale Issue is stale stage (outdated/stuck) labels Mar 30, 2022
@VojtechBartoska
Copy link
Contributor

Hello,

as there was no answer in last 14 days, I'm closing the issue as expired to keep our backlog manageable. If it's still needed, please reopen the issue.

Thanks for understanding.

@VojtechBartoska VojtechBartoska added Resolution: Expired More info wasn't provided and removed Resolution: Awaiting response Waiting for response of author labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues Resolution: Expired More info wasn't provided
Projects
None yet
Development

No branches or pull requests

4 participants