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

ESP8266 crashing on data received #51

Open
andrewgierens opened this issue Jan 5, 2021 · 11 comments
Open

ESP8266 crashing on data received #51

andrewgierens opened this issue Jan 5, 2021 · 11 comments

Comments

@andrewgierens
Copy link

Hello, I am having trouble with my ESP8266 crashing when data is received by the broker.

Here is all the information I have, if you need anything more specific let me know, any help would be appreciated.

Payload

{
  "o": "AA",
  "d": "AA",
  "s": "AAA",
  "p": "AAA"
}

Exception

Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x40209805: uMQTTBroker::_onData(unsigned int*, char const*, unsigned int, char const*, unsigned int) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 30
EXCVADDR: 0x00000012

Decoding stack results
0x402097f5: uMQTTBroker::_onData(unsigned int*, char const*, unsigned int, char const*, unsigned int) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 29
0x4021c542: new_linkoutput at glue-lwip/lwip-git.c line 260
0x4021cae4: ethernet_output at netif/ethernet.c line 312
0x40215340: uMQTTBroker::onAuth(String, String, String) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 59
0x40100c6f: free(void*) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 398
0x402097cc: uMQTTBroker::_onData(unsigned int*, char const*, unsigned int, char const*, unsigned int) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 26
0x40236c58: publish_topic at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\mqtt_server.c line 65
0x40100ca4: malloc(size_t) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 552
0x40237d34: find_topic at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\mqtt_topiclist.c line 73
0x40236c1c: publish_topic at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\mqtt_server.c line 58
0x40237984: MQTT_ClientCon_recv_cb at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\mqtt_server.c line 351
0x402267bc: mem_malloc at core/mem.c line 210
0x40225d10: ip4_output_if_opt at core/ipv4/ip4.c line 1577
0x40221101: tcp_create_segment at core/tcp_out.c line 190
0x40225d36: ip4_output_if at core/ipv4/ip4.c line 1550
0x402268c7: ip_chksum_pseudo at core/inet_chksum.c line 395
0x40221e16: tcp_output at core/tcp_out.c line 1361
0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x4023f12f: espconn_sent at glue-lwip/espconn.c line 421
0x4010015b: ets_intr_unlock() at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 163
0x40220299: pbuf_free_LWIP2 at core/pbuf.c line 726
0x4021c551: new_linkoutput at glue-lwip/lwip-git.c line 265
0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x4021c2b5: glue2esp_linkoutput at glue-esp/lwip-esp.c line 301
0x4021c542: new_linkoutput at glue-lwip/lwip-git.c line 260
0x4021cae4: ethernet_output at netif/ethernet.c line 312
0x40224280: etharp_output_to_arp_index at core/ipv4/etharp.c line 770
0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x402244d4: etharp_output_LWIP2 at core/ipv4/etharp.c line 885
0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x401009eb: umm_free_core(void*) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 351
0x40100c6f: free(void*) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 398
0x40100ca4: malloc(size_t) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 552
0x402267dc: mem_free at core/mem.c line 237
0x40100f02: calloc(size_t, size_t) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 908
0x4023fad5: espconn_server_recv at glue-lwip/espconn_tcp.c line 1189
0x4021ffc8: tcp_input at core/tcp_in.c line 501
0x4010060c: pvPortMalloc(size_t, char const*, int) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\heap.cpp line 271
0x40225a66: ip4_input at core/ipv4/ip4.c line 1467
0x40100c6f: free(void*) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 398
0x4021ca59: ethernet_input_LWIP2 at netif/ethernet.c line 188
0x4021c6f4: esp2glue_ethernet_input at glue-lwip/lwip-git.c line 469
0x4023e3de: ethernet_input at glue-esp/lwip-esp.c line 365
0x4023e3ef: ethernet_input at glue-esp/lwip-esp.c line 373
0x4010060c: pvPortMalloc(size_t, char const*, int) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\heap.cpp line 271
0x4021c2b5: glue2esp_linkoutput at glue-esp/lwip-esp.c line 301
0x40100ca4: malloc(size_t) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 552
0x4021c542: new_linkoutput at glue-lwip/lwip-git.c line 260
0x4021cae4: ethernet_output at netif/ethernet.c line 312
0x40223f78: etharp_raw at core/ipv4/etharp.c line 1165
0x4022416e: etharp_request at core/ipv4/etharp.c line 1202
0x402207e2: netif_issue_reports at core/netif.c line 916
0x40220888: netif_set_addr_LWIP2 at core/netif.c line 717

Sample class

class TestMqttBroker: public uMQTTBroker
{
public:
    virtual bool onConnect(IPAddress addr, uint16_t client_count) {
      // Serial.println(addr.toString()+" connected");
      return true;
    }

    virtual void onDisconnect(IPAddress addr, String client_id) {
      // Serial.println(addr.toString()+" ("+client_id+") disconnected");
    }
    
    virtual void onData(String topic, const char *data, uint32_t length) {
      
    }
};
@martin-ger
Copy link
Owner

Maybe a stack issue - could you try to replace the _onData function in uMQTTBroker.cpp with this version:

   void uMQTTBroker::_onData(uint32_t *args, const char* topic, uint32_t topic_len, const char *data, uint32_t length) {
	char *topic_str;
	
	if ((topic_str = (char *)malloc(topic_len+1)) == NULL)
	  return;

	os_memcpy(topic_str, topic, topic_len);
	topic_str[topic_len] = '\0';
	TheBroker->onData((String)topic_str, data, length);
	free(topic_str);
    }

@andrewgierens
Copy link
Author

Same-ish error

Ill keep looking on my end.

Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x40209292: uMQTTBroker::_onData(unsigned int*, char const*, unsigned int, char const*, unsigned int) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 33
EXCVADDR: 0x666e6f6f

Decoding stack results
0x40209282: uMQTTBroker::_onData(unsigned int*, char const*, unsigned int, char const*, unsigned int) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 32
0x40209254: uMQTTBroker::_onData(unsigned int*, char const*, unsigned int, char const*, unsigned int) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 25
0x40209274: uMQTTBroker::_onData(unsigned int*, char const*, unsigned int, char const*, unsigned int) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 28
0x4021c67c: ethernet_output at netif/ethernet.c line 312
0x40101238: umm_poison_free_fl(void*, char const*, int) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc/umm_local.c line 149
0x40209254: uMQTTBroker::_onData(unsigned int*, char const*, unsigned int, char const*, unsigned int) at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\uMQTTBroker.cpp line 25
0x402367f0: publish_topic at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\mqtt_server.c line 65
0x40100f49: check_poison_neighbors(uint16_t) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc/umm_local.c line 71
0x40101005: umm_malloc_core(size_t) at C:\Users\agierens\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 458
0x402378cc: find_topic at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\mqtt_topiclist.c line 73
0x402367b4: publish_topic at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\mqtt_server.c line 58
0x4023751c: MQTT_ClientCon_recv_cb at C:\Users\agierens\Documents\Arduino\libraries\uMQTTBroker-master\src\mqtt_server.c line 351

@martin-ger
Copy link
Owner

Seems to be in the copying of the topic string. Anything special with your topic str?

@andrewgierens
Copy link
Author

Nope, I just call subscribe("configure")

@pottendo
Copy link

hi Andrew,
which tool are you using to decode the stack?
I have the some tool 'ESP decoder' (sorry, don't have the name at hand now) which seems to work for esp32, but maybe not usable for esp8266 stacks.
thanks in advance,
pottendo

@andrewgierens
Copy link
Author

I use https://github.com/me-no-dev/EspExceptionDecoder

Seems to look to work for ESP8266? Let me know if you want anymore info, sorry just a bit confused by your question

@navdeepssidhu
Copy link

Hi,
i am also facing the same issue, could you please share how you resolved the issue?
thanks

@pottendo
Copy link

pottendo commented Mar 10, 2022 via email

@navdeepssidhu
Copy link

Thanks for the suggestion. I am interested in ESP broker (connected to cloud through GSM module) and would like to connect couple of Tasmota devices. Any help would be appreciated.
Thanks

@pottendo
Copy link

pottendo commented Mar 13, 2022 via email

@VovanPitersky
Copy link

Hi,
i am also facing the same issue, could you please share how you resolved the issue?
thanks

Hi,
i am also facing the same issue, could you please share how you resolved the issue?
thanks )))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants