-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Crashes since #6565 flashstring dedup #6574
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
Comments
The one change apps will see is that all PSTRs may no longer be aligned to 4-byte boundaries anymore due to coalescing (i.e. So code which assumed a by-4 alignment for PSTRs may have trouble (but by-4 was never guaranteed and is a relatively new addition). |
I assume it does also apply to F() macro strings, since I don't have that many PSTR defined strings in the code and the significant binary size reduction suggests a lot of deduped strings. |
F() uses PSTR() under the hood. @mhightower83, I have a niggling sensation that you had a by-4 alignment assumption for PSTRs somewhere in your code. Alignment should be by-4 unless the PSTR in question is made to point into another string (i.e. another PSTR of longer length ends with your full PSTR). |
Added a decoded stack trace to the start post. Perhaps it is already the first line in that function: const bool lineStartsWith_on = line.substring(0, 3).equalsIgnoreCase(F("on ")); I looks like the only calls of functions in the String class with F() strings are:
There is also a simple assignment, but that's unlikely the cause, since that is being used before this function is called. ( |
So the me21 script is not showing line numbers? That stinks, there's no reason it can't find lines, the exe used dumps them... Anyway, looks like you have a NULL pointer problem. Could be related to the F("on ") or the line.substring variable (in RAM). Can you give the ELF and MAP for the file that the crash comes from to check the address used for F("on "). Also, what would be most useful, can you get a MCVE from this so we can run ourselves and see the crash and peek around? |
How can I get the address of |
Just attach the ELF and MAP, I can open them up and see... |
Since I did make a new build (with NDEBUG removed as build flag) the stack trace may also be changed. Not sure where the map file is though, I don't see a file with map in the name in the .pio/build directory |
@mhightower83, my comment above looks to be in error. GCC and LD still obey the __align directive even when coalescing strings. A simple test shows it only merging strings which match on a by-4 address:
Shows
(i.e. str2 of (===str1 starting at 2nd char) was not merged w/str1, but str3, which could merge with str1 or str2 ended up merging w/str3 to ensure alignment.) |
Just looking at the code of String. For example: What if the new string objects are always a multiple of 4 in size, but the strlen like functions only return upto the first occurrence of a 0? String String::substring(unsigned int left, unsigned int right) const {
if(left > right) {
unsigned int temp = right;
right = left;
left = temp;
}
String out;
if(left >= len())
return out;
if(right > len())
right = len();
char temp = buffer()[right]; // save the replaced character
wbuffer()[right] = '\0';
out = wbuffer() + left; // pointer arithmetic
wbuffer()[right] = temp; //restore character
return out;
} And the function |
It's not a String problem, that bit has been stable for months as-is here and in the ESP32. I wouldn't waste time there. And strings are not a multiple of 4 in length, they're whatever size is allocated (or SSO'd). |
But you stated that a PSTR may no longer be bound to address multiples of 4. Edit: Edit2:
It does look like both strings |
Not following you there, sorry. It did merge str 2 and 3, but only because the alignment matched. If the strings were "ello, world!" and "yellow, world" then the linker would not combine them. PSTRs don't have any reason other than speed of access to need a 4-byte alignment (they didn't in prior releases), so in fact I might want to consider dropping the alignment for even better savings. Now it's probably getting mostly duplicated strings as opposed to any substring matches. Anyway, the crash in your code is in memmove. TRying to find if it;s source or destination. Could be an OOM condition in the code and not related to the change, but need more debug to see. If you can find a small app snippet that I can compile as opposed to the full app (which I can't because PIO and me never worked right for the 8266) that would speed things. |
GAS doesn't support the C language idiom of catenating two strings together with quotes (i.e. "x" "y" === "xy"). Specify the section attribute fully in the section attribute, instead, to allow this. Fixes esp8266#6575 and probably esp8266#6574
@earlephilhower In the meantime, could you please just: That's HEAD of master at the time of writing this, and breaks everything (like simplest WebServer demo). |
Thank you :-) |
@dok-net, do you have a sample of code that breaks because of the Not saying it's not a problem, but code inspection doesn't seem to show anything glaring, so maybe there's a corner case we're missing. |
Ah, I see it does kill HelloServer. Let me do some debug... |
I just applied the changes you made in WString.cpp for #6577 and it does now boot fine. N.B. did not change anything in the pgmspace file. Edit: Edit2: |
Thanks for the updates. The concatenated strings assembling w/o warnings or errors really bothers me. GAS just ignored the remainder of the line after the first ending quote instead of giving a syntax error ("unexpected junk after .string" or something I'd have hoped for). As I now have 2 reports of success, I'll merge that PR. When you have more runtime on the chip, report back, please. |
@earlephilhower Master works for me now, again. |
Great, thanks for the update @dok-net . |
#6577 is merged, and no new reports are in. If there are further problems, please open a new issue. |
Basic Infos
Platform
Settings in IDE
Problem Description
Update to last feature/stage state does reduce bin size, but also causes reboots with exception 28
See #6565 #6565 (comment)
Decoded stack trace:
It is a call to this function (and this revision of the file): https://github.com/letscontrolit/ESPEasy/blob/6267b9f00fbfbb9aedb61b408d51e17f76fd6330/src/ESPEasyRules.ino#L313-L422
The text was updated successfully, but these errors were encountered: