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 During Prints randomly #9069

Open
5 of 6 tasks
vgahlaut opened this issue Jan 11, 2024 · 2 comments
Open
5 of 6 tasks

ESP8266 Crashing During Prints randomly #9069

vgahlaut opened this issue Jan 11, 2024 · 2 comments

Comments

@vgahlaut
Copy link

vgahlaut commented Jan 11, 2024

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP8266
  • Core Version: Rel 3.1.2
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266 Module]
  • Flash Mode: [dio]
  • Flash Size: [4MB/1MB]
  • lwip Variant: [v1.4|v2 Lower Memory|Higher Bandwidth]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200] (serial upload only)

Problem Description

We have implemented IOT device. It works stable without any issue if we disable debug prints that we are printing using Serial.printf() . However When we enable printing It it crashes randmonly once out of around 5 -7 messages. With printing disabled it did not crash even once with 500 messages sent in loop.

We have checked the print statement, arguments but do not see anything wrong. For example we have below print statement

uint16_t *rawlen, uint32_t *freq, uint32_t mapid, uint32_t codeid;

Serial.printf("%s:Raw data len : %d Freq: %d retrieved for mapid:codeid %d:%d\r\n", __FUNCTION__, *rawlen, *freq, mapid, codeid);

Not sure if it is crashing on this print, but we tried to decode exception using plugin https://github.com/dankeboy36/esp-exception-decoder/actions and here are the exception and decoded details that seems to be pointing to DevNVStore.cpp:1115. Provided above is the print statement on this line. Entire code is too big to be shared.

Below is exception and its decoding

Exception (2):
epc1=0x3ffef420 epc2=0x00000000 epc3=0x00000000 excvaddr=0x3ffef420 depc=0x00000000

>>>stack>>>

ctx: sys
sp: 3fffecdc end: 3fffffb0 offset: 0150
3fffee2c:  3fffdab0 00000000 3fffdad0 3fff187c
3fffee3c:  4021de2e 3ffeb410 40000f49 ffffff00
3fffee4c:  40000f49 40000e19 0000003f 0000027c
3fffee5c:  3ffffed0 000005e0 00000000 40104685
3fffee6c:  3ffef450 0000003c 00000000 3ffffed0
3fffee7c:  00000100 0000001c 00000001 401057cd
3fffee8c:  3ffef450 3ffef420 3fffee2c 402438f1
3fffee9c:  3ffff268 3ffeeb80 00000000 00000000
3fffeeac:  feefeffe 401053b2 3ffef450 40104685
3fffeebc:  3ffef450 0000003c 40104d01 3ffef450
3fffeecc:  000000ff 0000001c 00000001 401057cd
3fffeedc:  3ffef450 401052b5 3ffef450 3ffeeb80
3fffeeec:  00040000 53000000 feefeffe 00000000
3fffeefc:  401025e8 4010558d 00080000 00000000
3fffef0c:  feefeffe 4010385a 40104a42 3ffef450
3fffef1c:  feefeffe 40104eb3 00000000 3ffef618
3fffef2c:  40103350 3ffebb5c 2c9f0300 4000050c
3fffef3c:  3fffc278 4010352c 3fffc200 00000022
3fffef4c:  00040000 00000000 00000000 00000020
3fffef5c:  401005d0 4000d529 00000032 00000000
3fffef6c:  401025e8 3ffeb2d0 40105867 3ffeeb80
3fffef7c:  00000202 00000001 40104a42 3ffef450
3fffef8c:  a0000000 40104eb3 20000000 3ffff210
3fffef9c:  00000030 4000d4e1 00000030 00000004
3fffefac:  ffffffff 4010497b 0000001e 00000000
3fffefbc:  00040000 00000000 00000006 402596bf
3fffefcc:  00000067 40103844 00080000 0000001f
3fffefdc:  401005d0 00000006 00000000 3fffc228
3fffefec:  40106119 4000050c 2c9f0300 4000050c
3fffeffc:  3fffc278 4010352c 3fffc200 00000022
3ffff00c:  00040000 40222d95 00000030 0000001c
3ffff01c:  ffffffff 40222d91 00000000 00000000
3ffff02c:  fffffffc 00000009 00000000 402596bf
3ffff03c:  0000000a 00000000 00000000 3ffff1a3
3ffff04c:  3ffff160 00000001 00000000 0000000a
3ffff05c:  00000000 00000001 00000000 0000000a
3ffff06c:  00000000 40227853 00000064 00000064
3ffff07c:  3ffea2e8 00000000 a0000000 00000000
3ffff08c:  0000001c 00001000 3fffc6fc 00001000
3ffff09c:  3ffe8368 00000000 00000000 3ffff210
3ffff0ac:  4022760c 3ffff19f 3ffff1a3 00000000
3ffff0bc:  000000fd 0000001c 00000001 40222dbd
3ffff0cc:  3ffe8368 00000004 00000000 3ffff210
3ffff0dc:  4022760c 40227548 3ffff19f 00000004
3ffff0ec:  00000000 401053b2 3ffef450 00000005
3ffff0fc:  3ffff210 3ffea2ec 00000000 3ffff160
3ffff10c:  40222eec 00000004 3ffeece8 3ffff170
3ffff11c:  3ffe8368 00000002 3ffe8368 3ffff210
3ffff12c:  4022760c 00000000 3ffea2ec 00000002
3ffff13c:  00000000 53000000 40104774 00040000
3ffff14c:  3ffea2ee 3ffea2ec 3ffe8368 3ffff210
3ffff15c:  40227809 00000000 ffffffff ffffffff
3ffff16c:  00000000 00000004 00000002 40302064
3ffff17c:  3fffc278 4010352c 3fffc200 00000022
3ffff18c:  40106119 4021ec51 00000030 00000010
3ffff19c:  31ffffff 00323330 00000000 00000033
3ffff1ac:  007f8000 6000001c 0000007e 00000000
3ffff1bc:  3ffff210 3ffff340 3ffff310 00000008
3ffff1cc:  3ffff2c2 3ffff340 3ffff310 00000008
3ffff1dc:  00000004 00000002 00000000 00002710
3ffff1ec:  00000030 00000002 3ffff340 00000008
3ffff1fc:  3fff1660 3ffff310 3ffe8368 00000040
3ffff20c:  40224a9d 3ffff2c2 3ffe8368 0000003d
3ffff21c:  ffff0208 3ffff2c0 0000003f 00000007
3ffff22c:  ffff0208 3ffff2d0 0000003f 00000040
3ffff23c:  40224a9d 3ffff30d 00000000 00000022
3ffff24c:  ffff0208 3ffff2f0 0000003f 4021df4a
3ffff25c:  00002710 00000000 00000000 3ffe85e0
3ffff26c:  00000002 00000000 00002710 4021df4a
3ffff27c:  3fffee90 00000000 00000008 3ffff2c1
3ffff28c:  4021efa8 3ffff2c2 fffffffc 00000008
3ffff29c:  4021efa8 3ffff308 fffffffc 00000008
3ffff2ac:  3fff1660 3ffff310 00000008 3ffff2c0
3ffff2bc:  4021c0a0 3200202c 61746100 6e654c20
3ffff2cc:  3a687467 31363120 007b0a0d 3d3d4154
3ffff2dc:  3d3d3d3d 0a0d3d3d 65722000 65697274
3ffff2ec:  20646576 20726f66 6970616d 6f633a64
3ffff2fc:  64696564 3ffff340 3ffff310 00000008
3ffff30c:  2d2d000a 3ffff350 3ffff320 fffffffc
3ffff31c:  3ffff2c4 0000007e 00000000 4025a151
3ffff32c:  00000000 00000001 3ffea2ec 3ffff340
3ffff33c:  40207b28 40004b31 3ffe9f23 3ffff350
3ffff34c:  0000003a 3fff4384 000000a1 3fff1660
3ffff35c:  4020853c 000000a0 3fff1660 00000000
3ffff36c:  40207b96 00000000 00000001 00000020
3ffff37c:  3fff4384 00000000 3fff1660 00000000
3ffff38c:  40205d7f 00000026 000000a1 3fff1660
3ffff39c:  4020876a 000000a1 3ffff3d0 00000001
3ffff3ac:  00000000 40207868 3ffff8d0 3fff1485
3ffff3bc:  3ffffe40 00000000 3fff1485 3ffff8d0
3ffff3cc:  40205dfc 00000001 00000001 00000000
3ffff3dc:  0000005a 00000026 0000000a fffffffc
3ffff3ec:  3ffff892 0000007e 00000000 40222645
3ffff3fc:  3ffe8368 0c008833 00060000 00002f03
3ffff40c:  00000000 00000000 00000000 00000000
3ffff41c:  00000000 00000000 00000000 00000000
3ffff42c:  00000000 00000000 00000000 00000000
3ffff43c:  00000000 0c808833 00060000 0000af03
3ffff44c:  00000000 00000000 00000000 00000000
3ffff45c:  00000000 00000000 00000000 00000000
3ffff46c:  00000000 00000000 00000000 00000000
3ffff47c:  00000000 10808833 113b3b3b 0000f200
3ffff48c:  00000000 00000000 00000000 00000000
3ffff49c:  00000000 00000000 00000000 00000000
3ffff4ac:  00000000 00000000 00000000 00000000
3ffff4bc:  00000000 11808833 113b3b3b 0000f100
3ffff4cc:  00000000 00000000 00000000 00000000
3ffff4dc:  00000000 00000000 00000000 00000000
3ffff4ec:  00000000 00000000 00000000 00000000
3ffff4fc:  00000000 12808833 113b3b3b 0000f000
3ffff50c:  00000000 00000000 00000000 00000000
3ffff51c:  00000000 00000000 00000000 00000000
3ffff52c:  00000000 00000000 00000000 00000000
3ffff53c:  00000000 13808833 113b3b3b 0000ef00
3ffff54c:  00000000 00000000 00000000 00000000
3ffff55c:  00000000 00000000 00000000 00000000
3ffff56c:  00000000 00000000 00000000 00000000
3ffff57c:  00000000 14808833 113b3b3b 0000ee00
3ffff58c:  00000000 00000000 00000000 00000000
3ffff59c:  00000000 00000000 00000000 00000000
3ffff5ac:  00000000 00000000 00000000 00000000
3ffff5bc:  00000000 15808833 113b3b3b 0000ed00
3ffff5cc:  00000000 00000000 00000000 00000000
3ffff5dc:  00000000 00000000 00000000 00000000
3ffff5ec:  00000000 00000000 00000000 00000000
3ffff5fc:  00000000 16808833 113b3b3b 0000ec00
3ffff60c:  00000000 00000000 00000000 00000000
3ffff61c:  00000000 00000000 00000000 00000000
3ffff62c:  00000000 00000000 00000000 00000000
3ffff63c:  00000000 17808833 113b3b3b 0000eb00
3ffff64c:  00000000 00000000 00000000 00000000
3ffff65c:  00000000 00000000 00000000 00000000
3ffff66c:  00000000 00000000 00000000 00000000
3ffff67c:  00000000 18808833 113b3b3b 0000ea00
3ffff68c:  00000000 00000000 00000000 00000000
3ffff69c:  00000000 00000000 00000000 00000000
3ffff6ac:  00000000 00000000 00000000 00000000
3ffff6bc:  00000000 19808833 113b3b3b 0000e900
3ffff6cc:  00000000 00000000 00000000 00000000
3ffff6dc:  00000000 00000000 00000000 00000000
3ffff6ec:  00000000 00000000 00000000 00000000
3ffff6fc:  00000000 19808833 113b3b3b 0000e900
3ffff70c:  00000000 00000000 00000000 00000000
3ffff71c:  00000000 00000000 00000000 00000000
3ffff72c:  00000000 00000000 00000000 00000000
3ffff73c:  00000000 1b808833 113b3b3b 0000e700
3ffff74c:  00000000 00000000 00000000 00000000
3ffff75c:  00000000 00000000 00000000 00000000
3ffff76c:  00000000 00000000 00000000 00000000
3ffff77c:  00000000 1c808833 113b3b3b 0000e600
3ffff78c:  00000000 00000000 00000000 00000000
3ffff79c:  00000000 00000000 00000000 00000000
3ffff7ac:  00000000 00000000 00000000 00000000
3ffff7bc:  00000000 1d808833 113b3b3b 0000e500
3ffff7cc:  00000000 00000000 00000000 00000000
3ffff7dc:  65746164 6e6f6d5f 00000515 00000000
3ffff7ec:  9c0004f0 00007f52 9c0004f0 00007f52
3ffff7fc:  9c00bfa0 00007f52 9c00bfa0 00007f52
3ffff80c:  9c00cd10 00007f52 9c00bfe8 00007f52
3ffff81c:  00000040 00000000 00000044 00000000
3ffff82c:  6929002b 00007f55 00000018 00000000
3ffff83c:  00000001 00000001 00000001 00000007
3ffff84c:  00000026 0000000d 9c00c028 00007f52
3ffff85c:  00000080 00000000 00000044 00000000
3ffff86c:  6929010c 00007f55 00000018 00000000
3ffff87c:  00000000 00000000 00000018 00000000
3ffff88c:  3fff1485 3fff1485 3ffff8d0 00000010
3ffff89c:  40205e6a 3ffffe40 00000001 0000000a
3ffff8ac:  3ffe9488 00000000 a0000000 00000000
3ffff8bc:  3fff4356 3fff1485 3fff1488 3fff4284
3ffff8cc:  40206280 00000001 00000000 00000000
3ffff8dc:  00000001 00000000 00000000 00000000
3ffff8ec:  00000000 00000000 00000000 00000000
3ffff8fc:  00000000 00000000 00000000 00000000
3ffff90c:  00000000 00000000 00000000 00000000
3ffff91c:  00000000 00000000 40105867 3ffeea68
3ffff92c:  3ffffa40 3ffe94ad 00000000 3ffff990
3ffff93c:  40222eec 00000001 1f0e2404 3ffef618
3ffff94c:  3ffe8368 00000002 3ffe8368 3ffffa40
3ffff95c:  4022760c 00000000 3ffe94ad 00000002
3ffff96c:  00000000 00002200 40104774 00040000
3ffff97c:  3ffe94af 3ffe94ad 3ffe8368 3ffffa40
3ffff98c:  40227809 00000000 00000000 0000001f
3ffff99c:  401005d0 00000001 00000020 3fffc228
3ffff9ac:  40106119 4000050c 3fffc200 00000022
3ffff9bc:  401025e8 4021ec51 00000030 00000018
3ffff9cc:  ffffffff 40104777 00040000 00000000
3ffff9dc:  00040000 50530000 40104774 00040000
3ffff9ec:  3ffffa40 3ffef450 00000000 3ffff9d3
3ffff9fc:  000000f7 000000de 00000001 401057cd
3ffffa0c:  3ffef498 3ffef420 2c9f0300 4000050c
3ffffa1c:  3fffc278 4010352c 3fffc200 00000022
3ffffa2c:  3ffef450 401053b2 3ffef498 00000011
3ffffa3c:  ffffffff 4000da01 40104d01 3ffef498
3ffffa4c:  00000000 00000001 00013000 6763845e
3ffffa5c:  0000000a 401052b5 3ffef498 3ffeea68
3ffffa6c:  00040000 00000001 00000000 0000000a
3ffffa7c:  00000000 00000001 00000000 0000000a
3ffffa8c:  00000000 4010385a 00000020 00000000
3ffffa9c:  401025e8 00000000 a0000000 00000000
3ffffaac:  0000001c 00001000 2c9f0300 00001000
3ffffabc:  3ffe8368 00000000 00000000 3ffffc30
3ffffacc:  4022760c 3ffffbc2 3ffffbc3 00000000
3ffffadc:  ffffffff 4022760c 00000003 40222dbd
3ffffaec:  3ffe8368 00000001 00000000 3ffffc30
3ffffafc:  4022760c 40227548 3ffffbc2 00000001
3ffffb0c:  00000000 3ffffdb1 00000002 3ffe8368
3ffffb1c:  3ffffc30 3ffe96f3 00000000 3ffffb80
3ffffb2c:  40222eec 00000001 00000000 00001000
3ffffb3c:  3ffe8368 00000002 3ffe8368 3ffffc30
3ffffb4c:  4022760c 00000000 3ffe96f3 00000002
3ffffb5c:  00000000 00002000 00000000 40222dbd
3ffffb6c:  3ffe96f5 3ffe96f3 3ffe8368 3ffffc30
3ffffb7c:  40227809 00000000 ffffffff ffffffff
3ffffb8c:  00000000 00000001 00000027 40302064
3ffffb9c:  3ffffcb0 3ffe978d 00000000 3ffffc00
3ffffbac:  40222eec 00000003 3ffffc69 0000000a
3ffffbbc:  3ffe8368 00310002 3ffe8368 3ffffcb0
3ffffbcc:  4022760c 00000000 3ffe978d 00000000
3ffffbdc:  00000000 3ffffd60 3ffffd30 0000000c
3ffffbec:  3ffe978f 3ffffd60 3ffffd30 00000008
3ffffbfc:  00000001 00000002 ffffffff ffffffff
3ffffc0c:  00000000 00000003 00000024 3f302064
3ffffc1c:  3fff1660 3ffffd30 3ffe8368 00000040
3ffffc2c:  40224a9d 3ffffd07 ffffffff 00000018
3ffffc3c:  ffff0208 3ffffce0 0000003f 00302064
3ffffc4c:  00000000 00000000 00000000 00000000
3ffffc5c:  3ffea28a 3ffffde0 3ffffdb0 0000000c
3ffffc6c:  34363638 3ffffde0 3ffffdb0 00000008
3ffffc7c:  00000003 00000000 00000000 3ffe85e0
3ffffc8c:  00000027 00000000 00002710 4021df4a
3ffffc9c:  00002710 00000000 00000027 3ffffcf5
3ffffcac:  4021efa8 3ffffd07 fffffffc 00000008
3ffffcbc:  ffff0208 3ffffd60 0000003f 00000000
3ffffccc:  3fff1660 3ffffd30 00000008 3ffffce0
3ffffcdc:  4021c0a0 20202020 20202020 65646f43
3ffffcec:  2d2d6469 2d2d2d2d 2d2d2d2d 2d2d2d2d
3ffffcfc:  2d2d2d2d 203a2d2d 000a0d31 3ffef618
3ffffd0c:  3fff1660 3ffffe20 3ffe8368 00000040
3ffffd1c:  40224a9d 3ffffd60 3ffffd30 00000008
3ffffd2c:  4021efa8 3ffffd84 fffffffc 00000001
3ffffd3c:  3ffffd07 0000007e 00000002 00000010
3ffffd4c:  3fff1660 3ffffdb0 3ffe96cd 3ffffd60
3ffffd5c:  4021c0a0 20202020 52492020 45584520
3ffffd6c:  00001388 3fff1488 3fff1488 3fff1660
3ffffd7c:  40204b6d 00000001 00000000 00000000
3ffffd8c:  00000001 00000000 00000000 00000000
3ffffd9c:  00000000 00000000 00000000 00000000
3ffffdac:  00000000 00000000 00000000 00000000
3ffffdbc:  00000000 3ffffe40 00000000 00000000
3ffffdcc:  79838cb2 3fff4264 3fff1488 00000020
3ffffddc:  3fff432e 3fff4264 3fff1488 3fff42fc
3ffffdec:  4020638e 00000004 00000070 3fff4264
3ffffdfc:  40204c38 00000004 00000070 3ffffe10
3ffffe0c:  40100d96 00000082 3ffffe40 00000050
3ffffe1c:  3fff1485 40254eba 3fff4234 3fff0964
3ffffe2c:  00001388 3fff119f 3fff1660 3fff4234
3ffffe3c:  402067c9 00000000 3ffea272 3ffffe50
3ffffe4c:  000000c0 3fff1660 3fff0964 00000020
3ffffe5c:  000000c0 3fff1660 3fff0964 3fff4234
3ffffe6c:  4020840c 3fff0964 3fff0f80 00000000
3ffffe7c:  3fff187c 3fff0964 3fff0f80 000000c0
3ffffe8c:  40203ed2 3fffdad0 00000000 3fff1850
3ffffe9c:  4021e0c8 feefeffe feefeffe 3fffdab0
3ffffeac:  40100529 feefeffe 3fffee90 0000027c
3ffffebc:  3ffffed0 4010fda5 00000004 00000008
3ffffecc:  4010feae 00000000 00000000 00000000
3ffffedc:  3f000000 00000000 400042db 3ffeade0
3ffffeec:  00000001 00000000 401000c0 00000001
3ffffefc:  401000b8 00001000 60000200 00000000
3fffff0c:  00000000 0000027c 00000000 000643a0
3fffff1c:  40100000 000027c0 5ffffe00 00000000
3fffff2c:  00ff0000 401006a9 000003fc 00000000
3fffff3c:  3ffffec2 400203e9 40100438 ffffffff
3fffff4c:  ffffe6fc ffffffff 3fffff70 00000004
3fffff5c:  4000177a 02040005 02050505 05040005
3fffff6c:  05050405 fffdfe04 e0f0f0f0 0ae1e0e0
3fffff7c:  00f8ffff 4e52f8f8 3840444a 01010000
3fffff8c:  05040302 00000001 00020000 00000000
3fffff9c:  00000000 00000ae1 00000000 93010000
3fffffac:  00000043 00000000 00000000 00000000
<<<stack<<<


Exception 2: InstructionFetchError: Processor internal physical address or data error during instruction fetch
PC: 0x3ffef420
EXCVADDR: 0x3ffef420

Decoding stack results
0x4021de2e: loop_task(ETSEvent*) at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:273
0x401005d0:  is in ets_post(uint8, ETSSignal, ETSParam) (C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:238).
0x401005d0:  is in ets_post(uint8, ETSSignal, ETSParam) (C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:238).
0x40222d95: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:193
0x40222d91: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:193
0x40227853: _svfprintf_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:551
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x40222dbd: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:194
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x40227548: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:182
0x40222eec: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:246
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x40227809: _svfprintf_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:528
0x4021ec51:  is in uart_do_write_char(int, char) (C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\uart.cpp:513).
0x40224a9d: _vsnprintf_r at /workdir/repo/newlib/newlib/libc/stdio\vsnprintf.c:71
0x40224a9d: _vsnprintf_r at /workdir/repo/newlib/newlib/libc/stdio\vsnprintf.c:71
0x4021df4a: __yield() at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_features.h:64
0x4021df4a: __yield() at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_features.h:64
0x4021efa8:  is in uart_write(uart_t*, char const*, size_t) (C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\uart.cpp:547).
0x4021efa8:  is in uart_write(uart_t*, char const*, size_t) (C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\uart.cpp:547).
0x4021c0a0:  is in Print::printf(char const*, ...) (C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\Print.cpp:66).
0x40207b28:  is in DevNVStore::read_rawdataparam(unsigned short*, unsigned int*, unsigned int, unsigned int) (d:\Arduino\IR11-Arduino\libraries\irdev\DevNVStore.cpp:1115).
0x4020853c:  is in DevUtils::irRawDataDump(unsigned short*, unsigned short) (d:\Arduino\IR11-Arduino\libraries\irdev\DevUtils.cpp:158).
0x40207b96:  is in DevNVStore::read_rawdata(unsigned short*, unsigned short, unsigned int, unsigned int) (d:\Arduino\IR11-Arduino\libraries\irdev\DevNVStore.cpp:1135).
0x40205d7f:  is in DevFSM::irConfigExecute(unsigned int, unsigned int, devIrConfigDevReq_st*, int*) (d:\Arduino\IR11-Arduino\libraries\irdev\DevFSM.cpp:1134).
0x4020876a: DevUtils::irRawConfigDump(devIrConfigDevReq_st*) at d:\Arduino\IR11-Arduino\libraries\irdev\DevUtils.cpp:229
0x40207868:  is in DevNVStore::read_irconfig(unsigned char*, unsigned int) (d:\Arduino\IR11-Arduino\libraries\irdev\DevNVStore.cpp:948).
0x40205dfc:  is in DevFSM::irExecuteMapid(unsigned int, devIrExecuteCodeReq_st*, int*) (d:\Arduino\IR11-Arduino\libraries\irdev\DevFSM.cpp:1094).
0x40222645: _printf_float at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_float.c:306
0x40205e6a:  is in DevFSM::irExecute(devIrExecuteCodeReq_st*, int*) (d:\Arduino\IR11-Arduino\libraries\irdev\DevFSM.cpp:1064).
0x40206280:  is in DevFSM::process_gen_apis(dev_gen_hdr_st*, unsigned char*, unsigned char*, int*) (d:\Arduino\IR11-Arduino\libraries\irdev\DevFSM.cpp:974).
0x40222eec: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:246
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x40227809: _svfprintf_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:528
0x401005d0:  is in ets_post(uint8, ETSSignal, ETSParam) (C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:238).
0x4021ec51:  is in uart_do_write_char(int, char) (C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\uart.cpp:513).
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x40222dbd: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:194
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x40227548: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:182
0x40222eec: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:246
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x40222dbd: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:194
0x40227809: _svfprintf_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:528
0x40222eec: _printf_i at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf_i.c:246
0x4022760c: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio\nano-vfprintf.c:232
0x40224a9d: _vsnprintf_r at /workdir/repo/newlib/newlib/libc/stdio\vsnprintf.c:71

Can someone please help? Is it stack smashing? If yes how could such simple print can cause stack to be corrupted?

Do you see any issue in Serial.printf implementation in core?


### Debug Messages

Debug messages go here



@vgahlaut
Copy link
Author

vgahlaut commented Jan 12, 2024

Hi Experts,

Now we have commented particular printf as reported in previous message and decoded stack and run it again. Now every time we are seeing stack smashing every time as below but with exception decoder unable to figure out problem. Can you please help us where to look in to code. Decoded exception does not show any code written by us, its all SDK code

Stack smashing detected.

Exception (5):
epc1=0x40100553 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: sys
sp: 3ffffe80 end: 3fffffb0 offset: 0000
3ffffe80:  3fffdad0 00000000 3fff1810 40100553
3ffffe90:  3fffdad0 00000000 3fff1810 4021e09b
3ffffea0:  feefeffe feefeffe 3fffdab0 40100529
3ffffeb0:  feefeffe 3fffee90 00000278 3ffffed0
3ffffec0:  4010fda5 00000004 00000008 4010feae
3ffffed0:  00000000 00000000 00000000 9a000000
3ffffee0:  00000000 400042db 3ffeada0 00000001
3ffffef0:  00000000 401000c0 00000001 401000b8
3fffff00:  00001000 60000200 3fffffb0 3ffffe30
3fffff10:  00000278 00000000 00064320 40100000
3fffff20:  00002780 5ffffe00 00000000 00ff0000
3fffff30:  401006a9 000003fc 00000000 3ffffec2
3fffff40:  400203e9 40100438 ffffff00 ffffe6fc
3fffff50:  ffffffff 3fffff70 00000004 4000177a
3fffff60:  00ff0000 383d373d 343e363e 00000000
3fffff70:  00000000 003c1d0d 003c003c 003c007c
3fffff80:  0f03090f 070f0307 03070f03 fe85130c
3fffff90:  4a4e800e 383c4046 0702fdfa 02fe0e0b
3fffffa0:  12100c07 100a0502 05021613 1613100a
<<<stack<<<


Exception 5: Alloca: MOVSP instruction, if caller's registers are not in the register file
PC: 0x40100553: cont_check(cont_t*) at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\cont_util.cpp:56
EXCVADDR: 0x00000000

Decoding stack results
0x40100553: cont_check(cont_t*) at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\cont_util.cpp:56
0x4021e09b: loop_wrapper() at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:260
0x401000c0: app_entry() at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:392
0x401000b8: app_entry_redefinable() at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:386
0x401006a9: uart_write_char_d(char) at C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_postmortem.cpp:310

@mcspr
Copy link
Collaborator

mcspr commented Jan 19, 2024

^ dump above just means crash had happened, same as 'Exception' line is used to fit into existing crash format. At that point stack is already rolled back and we are calling cont_check that causes the panic
(although, I wonder if we should use a different format here)

One way to guard against stack usage is to enable 'stack protection' option from the IDE menu, which would force the stack check after every function call instead of just after user task suspends (yield(), delay(), esp_suspend(), esp_yield()). This way crash would happen while inside of some function, not within our

While that is enabled, you could also amend build flags with -Wstack-usage=NUM where NUM can be any number of bytes we are worried about

edit: Either by creating SKETCH_NAME.ino.globals.h in the root of the sketch folder

/*@create-file:build.opt@
-Wstack-usage=512
*/

Or, editing build flags for board stack protector option. For generic board like you mentioned in the template above

generic.menu.stacksmash.enabled.build.stacksmash_flags=-fstack-protector
generic.menu.stacksmash.enabled.build.stacksmash_flags=-fstack-protector -Wstack-usage=512

I would also suggest going lower even to possibly catch some nested calls causing stack to grow too much. Note that build log size would greatly increase.
See C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\boards.txt and find your specific board, modify the .txt and reload the IDE. Make sure build warnings are enabled in the preferences menu, otherwise it wouldn't print anything.

Maybe related to #8666

mcspr added a commit to mcspr/esp8266-Arduino that referenced this issue Feb 5, 2024
- check in cont_run() and cont_suspend() whether a1 is out of bounds
- in case a1 is broken, postmortem will still report proper context in
  proper stack boundaries

additionally
- as suggested in esp8266#9069, change stack smashing to a single line that
  does not mention any Exceptions
- reduce overall stack dump length when there are know garbage values i.e. cont stackguard
- decoder.py addr search regexp would no longer skip stack lines with '<'
- fix decoder.py parsing so it notices both stack smashing and alloc errors
mcspr added a commit that referenced this issue Mar 26, 2024
- check in cont_run() and cont_suspend() whether a1 is out of bounds
- in case a1 is broken, postmortem will still report proper context in
  proper stack boundaries

additionally
- as suggested in #9069, change stack smashing to a single line that
  does not mention any Exceptions
- reduce overall stack dump length when there are know garbage values i.e. cont stackguard
- decoder.py addr search regexp would no longer skip stack lines with '<'
- fix decoder.py parsing so it notices both stack smashing and alloc errors
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

2 participants