I created a completely separate program to test strstr() when called several levels deep (see below) and of course, it works fine (ugh!). I included a 300-byte local variable buffer at each level to try to simulate a "large" stack. So it must be something about the particular code that I was calling it from, although it's weird that it works fine without the one line that calls strstr() and then crashes when I uncomment the line. So I'll keep testing to try to get more clues. If you're curious, below is the separate test code I created.
Code:
#include <Arduino.h>
void Level1();
void Level2();
void Level3();
void Level4();
void setup() {
char *p;
char dummy[300];
Serial.begin(115200);
delay(3000);
p = strstr("Test string 0", "str");
if (p != NULL) {
Serial.print("Level 0: ");
Serial.println(p);
}
Level1();
}
void Level1() {
char *p;
char dummy[300];
p = strstr("Test string 1", "str");
if (p != NULL) {
Serial.print("Level 1: ");
Serial.println(p);
}
Level2();
}
void Level2() {
char *p;
char dummy[300];
p = strstr("Test string 2", "str");
if (p != NULL) {
Serial.print("Level 2: ");
Serial.println(p);
}
Level3();
}
void Level3() {
char *p;
char dummy[300];
p = strstr("Test string 3", "str");
if (p != NULL) {
Serial.print("Level 3: ");
Serial.println(p);
}
Level4();
}
void Level4() {
char *p;
char dummy[300];
p = strstr("Test string 4", "str");
if (p != NULL) {
Serial.print("Level 4: ");
Serial.println(p);
}
}
void loop() {
// put your main code here, to run repeatedly:
}