I have a very strange situation.
I have this code:
for (int b = 0 ; b <= CHANNEL_COUNT ; ++b) {
deleteChannel(b);
}
deleteChannel is declared as a private function within the class as follows:
void RemoteSign::deleteChannel(int ch)
CHANNEL_COUNT is equal to 9. a const int
On an EP8266 the code crashes after the for loop. The functionality in deleteChannel() is carried out correctly.
If I replace the loop with this code:
deleteChannel(0);
deleteChannel(1);
deleteChannel(2);
deleteChannel(3);
deleteChannel(4);
deleteChannel(5);
deleteChannel(6);
deleteChannel(7);
deleteChannel(8);
deleteChannel(9);
Then there is no crash after doing all 10 calls.
Obviously I don't want to hard code the number of channels.
Any clues as to the possible cause?
Here is the stack trace:
18:37:04.408 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
18:37:04.455 ->
18:37:04.455 -> Exception (29):
18:37:04.455 -> epc1=0x4000e143 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000001 depc=0x00000000
18:37:04.455 ->
18:37:04.455 -> >>>stack>>>
18:37:04.455 ->
18:37:04.455 -> ctx: cont
18:37:04.455 -> sp: 3fff26d0 end: 3fff2aa0 offset: 0190
18:37:04.455 -> 3fff2860: 00000006 00000005 3fff28c8 40231d28
18:37:04.455 -> 3fff2870: 3fff28b0 00000006 3fff0238 40231d28
18:37:04.455 -> 3fff2880: 0000000b 3fff0238 3fff0238 40231fa9
18:37:04.455 -> 3fff2890: 3ffe8a12 3fff28bc 0000000a 3ffef6dc
18:37:04.455 -> 3fff28a0: 0000000b 3fff0238 0000000a 40221f4a
18:37:04.455 -> 3fff28b0: 312f6800 00000030 80000009 00003000
18:37:04.455 -> 3fff28c0: 00000001 80000009 312f6863 40230030
18:37:04.501 -> 3fff28d0: 85ff29d0 3fff2924 3ffef6a0 3ffef6dc
18:37:04.501 -> 3fff28e0: 0000000b 0000000b 3ffef6a0 40224ae6
18:37:04.501 -> 3fff28f0: 00418937 00cb4c4a 00000000 0000000a
18:37:04.501 -> 3fff2900: 45521100 41544553 80004c4c 40100d3c
18:37:04.501 -> 3fff2910: 4000050c 00000030 00000010 00000000
18:37:04.501 -> 3fff2920: 3fff154c 45520000 41544553 80004c4c
18:37:04.501 -> 3fff2930: 40228518 3fff3604 00000001 43b35eac
18:37:04.501 -> 3fff2940: 00000000 00000000 3fff3b00 0010001f
18:37:04.501 -> 3fff2950: 80ffffff 3fffc6fc 00000001 0000000a
18:37:04.501 -> 3fff2960: 45534552 4c4c4154 88ff2a00 40231bf2
18:37:04.549 -> 3fff2970: 392f6863 3ffe8500 84ff0848 00000000
18:37:04.549 -> 3fff2980: 3fff35b4 00000010 3fff2a30 40231bf2
18:37:04.549 -> 3fff2990: 40233024 3ff00014 00000000 3fff0848
18:37:04.549 -> 3fff29a0: 0000000b 00000000 00000020 40100d07
18:37:04.549 -> 3fff29b0: 00000000 00000000 4bc6a7f0 3fff0848
18:37:04.549 -> 3fff29c0: 3fff35b4 0000000f 3fff2a30 40231cdf
18:37:04.549 -> 3fff29d0: 45521139 41544553 8a004c4c 4843447b
18:37:04.549 -> 3fff29e0: 003c007d 8500000f 3fff2a30 40231d28
18:37:04.549 -> 3fff29f0: 3fff2a30 00000000 00000000 40231f0c
18:37:04.549 -> 3fff2a00: 00000000 00000000 3fff2a30 40231f3c
18:37:04.549 -> 3fff2a10: 3fff2a48 3ffef684 3fff2a48 3fff0848
18:37:04.596 -> 3fff2a20: 3ffe8504 3ffef6a0 3ffef684 40226911
18:37:04.596 -> 3fff2a30: 3fff35cc 000f000f 00001388 4022685a
18:37:04.596 -> 3fff2a40: 007a1200 43bd3189 3fff35b4 000f000f
18:37:04.596 -> 3fff2a50: 0a005345 80efeffe 2d505300 43393830
18:37:04.596 -> 3fff2a60: 00000000 00000000 00000001 3fff1400
18:37:04.596 -> 3fff2a70: 3fffdad0 00000000 3fff13c0 40226a98
18:37:04.596 -> 3fff2a80: feefeffe feefeffe 3fff13c0 40233038
18:37:04.596 -> 3fff2a90: feefeffe feefeffe 3ffe8558 40100fcd
18:37:04.596 -> <<<stack<<<
18:37:04.596 ->
and the exception decoder results:
xception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores PC: 0x4000e143 EXCVADDR: 0x00000001 Decoding stack results 0x40231d28: String::copy(char const, unsigned int)* at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 214 0x40231d28: String::copy(char const, unsigned int)* at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 214 0x40231fa9: String::operator=(char const)* at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 285 0x40221f4a: RemoteSign::deleteChannel(int) at C:\ard\common/RemoteSign.cpp line 3421 0x40230030: EspClass::getSketchSize() at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*Esp.cpp* line 582 0x40224ae6: RemoteSign::handleRS(String) at C:\ard\common/RemoteSign.cpp line 2086 0x40100d3c: malloc(size_t) at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc*umm_malloc.cpp* line 552 0x40228518: WiFiClient::operator=(WiFiClient const&) at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src*WiFiClient.cpp* line 117 0x40231bf2: String::changeBuffer(unsigned int) at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 187 0x40231bf2: String::changeBuffer(unsigned int) at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 187 0x40233024: loop_wrapper() at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*core_esp8266_main.cpp* line 192 0x40100d07: free(void)* at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc*umm_malloc.cpp* line 398 0x40231cdf: String::reserve(unsigned int) at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 146 0x40231d28: String::copy(char const, unsigned int)* at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 214 0x40231f0c: String::operator=(String const&) at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 262 0x40231f3c: String::String(String const&) at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*WString.cpp* line 41 0x40226911: RemoteSign::run() at C:\ard\common/RemoteSign.cpp line 2833 0x4022685a: setup() at C:\Ard\GenericRS\GenericRS/GenericRS.ino line 43 0x40226a98: loop() at C:\Ard\GenericRS\GenericRS/GenericRS.ino line 47 0x40233038: loop_wrapper() at C:\Users\ms\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266*core_esp8266_main.cpp* line 197