-
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
Static initialization guards implementation #1586
Conversation
This alignment prevents umm_malloc to detect buffer overruns which fall within padding introduced by new/new[]. Allocated memory will be aligned by design of umm_malloc, so we don't need to pad anything here. Also fixed some formatting/newlines and removed unused header files.
Looks good to me, just tested this and works great in my (previously broken) app. |
Looks like the issue is gone with this fix. Thanks a lot. |
Guys, I clearly understand this problem, so does this mean now best practices are not using static declaration ? sure we can use them but we're not able to initialize them. so avoid this
And do that ?
is that correct ? |
Static initialization guards implementation
this code change brakes some of my projects,
the reason is the malloc change, the umm makes problems. |
Latest malloc changes cause Telnet example crash and reboot in loop |
check #1630 |
Yep, I got interrupt locks wrong, testing a fix here. |
Hello, I don't fully understand how git up works- can you advise whether this is now sorted? How can I go about updating the Arduino IDE to use the new code? |
This pull request adds implementation of libsupc++ functions which are used by gcc to protect local static initializers.
Interrupts are disabled for the duration of static initialization. This is not ideal, but i don't see a way to implement this without disabling interrupts. Imagine the following scenario:
Let's consider the case when
first_millis
is called fromsetup
first, and GPIO interrupt happens at the point whenmillis
is being executed. Execution context is switched toisr_handler
, which callsfirst_millis
again. C++ standard requires static initialization to be finished before execution is allowed to proceed further, but since we are now inside an interrupt, there is no way of doing that. ISR has higher priority andmillis
will proceed only when ISR is finished.Therefore I think we have to live with interrupts disabled for the duration of static initialization.