-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
WString: make to be safer init state, in order to tolerate (potential) stray dtor calls #7590
Conversation
…) stray dtor calls derived from esp8266#7553
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how this affects the c'tor/d'tor one way or the other. It just seems to change the name and inverting the logic for SSO flags.
If that flag itself is not set somewhere before being used in a d'tor, you have to assume it's random. So, still the 50% chance of trying to free
something that wasn't allocated.
i think so - the idea do not belong to me :) even w/o this PR, dtor do not call
because
a some other weak reasons:
potential... (negligible in fact) |
Steps to reproduce it...
|
@TD-er can you give an MCVE for that, one that fails for you? Seems straightforward enough (and you can do a |
post-OOM behavior... virtually impossible to keep heap integrity, should dump so to debug serial and |
Well I do always check large object allocations whether they return nullptr. |
I will try to find some time for it this weekend. |
post-OOM condition is typical corner-case and thus mentioned above, if BSS still keeps its consistency, global dtor do not call this is just why virtually impossible. the main interest: is this PR sufficient to resolve your problem? |
On further inspection, I'm really not seeing anything this changes and I'm not seeing how String() could free an invalid pointer and cause a crash like @TD-er is thinking. My reasoning: All Arduino/cores/esp8266/WString.cpp Lines 131 to 135 in a460cb7
If the constructor is called with a So, the only way it doesn't crash is with a valid Now on destruction (which cannot ever happen if the c'tor Arduino/cores/esp8266/WString.cpp Lines 123 to 125 in a460cb7
Arduino/cores/esp8266/WString.cpp Lines 137 to 141 in a460cb7
So, we check the So, this PR doesn't change anything or affect the behavior in any way. And, as far as I can see, the existing behavior is safe and sane. If memory gets corrupted elsewhere, or the String |
thanks for the discussion, this PR is melt back into #7553 and closed. |
derived from #7553