Skip to content

String += PSTR() crashes (and it should on Arduino, but can esp8266 be more flexible?) #6367

Closed
@everslick

Description

@everslick

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: [ESP-12]
  • Core Version: [d6973cd]
  • Development Env: [Make]
  • Operating System: [Ubuntu]

Settings in IDE

  • Module: [Generic ESP8266 Module]
  • Flash Mode: [dio]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [ck]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [160MHz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200)

Problem Description

Exception 3 when I concatenate a global const char * that is declared to be stored in flash via the PSTR() macro to a String object.

Last known good git version is: 0ab76fc from 2019/05/09

MCVE Sketch

#include "Arduino.h"

static const char *gpstr;
static String gstr = "foo";

void setup(void) {
  Serial.begin(115200);

  Serial.println("Start");
  gpstr = PSTR("string stored in flash");

  Serial.println("Before Crash");
  gstr += gpstr; // << crash
  Serial.println("Not reached");
}

Debug Messages

ets Jan  8 2013,rst cause:2, boot mode:(3,6)                                            
                                                                                         
load 0x4010f000, len 1384, room 16                                                       
tail 8                                                                                   
chksum 0x2d                                                                              
csum 0x2d                                                                                
v00000000                                                                                
~ld                                                                                      
Start                                                                                 
Before Crash                                                                             
                                                                                         
Exception (3):                                                                           
epc1=0x40235680 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4027be94 depc=0x
00000000                                                                                 
>>>stack>>>                                                                      
ctx: cont                                                             
sp: 3fff1250 end: 3fff1460 offset: 01a0

Stacktrace

clemens@secrets:~/Devel/ESP/emonio-fw/src$ make stack 
0x3ffefdd0: ?? at /home/clemens/Devel/ESP/emonio-fw/src/emonio.ino:4
0x40202331: Print::write(char const*) at /home/clemens/Devel/ESP/emonio-fw/src/../../Arduino-ESP8266/cores/esp8266/Print.h:60
0x3ffefdd0: ?? at /home/clemens/Devel/ESP/emonio-fw/src/emonio.ino:4
0x40229864: String::concat(char const*) at /home/clemens/Devel/ESP/emonio-fw/src/../../Arduino-ESP8266/cores/esp8266/WString.cpp:342
0x4027be94: umm_block_size at ??:?
0x3ffefdd0: ?? at /home/clemens/Devel/ESP/emonio-fw/src/emonio.ino:4
0x402282bc: Print::println(char const*) at /home/clemens/Devel/ESP/emonio-fw/src/../../Arduino-ESP8266/cores/esp8266/Print.cpp:190
0x3ffefdd0: ?? at /home/clemens/Devel/ESP/emonio-fw/src/emonio.ino:4
0x402020c0: setup at /home/clemens/Devel/ESP/emonio-fw/src/emonio.ino:25
0x402011f0: loop_wrapper() at /home/clemens/Devel/ESP/emonio-fw/src/../../Arduino-ESP8266/cores/esp8266/core_esp8266_main.cpp:137
0x3ffe8618: ?? at /home/clemens/Devel/ESP/emonio-fw/src/../../Arduino-ESP8266/cores/esp8266/core_esp8266_main.cpp:55
0x40100221: cont_wrapper at /home/clemens/Devel/ESP/emonio-fw/src/../../Arduino-ESP8266/cores/esp8266/cont.S:81

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions