RTC.begin() crashes whole processor #88
Labels
conclusion: resolved
Issue was resolved
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
This function is declared to have return value
bool
ArduinoCore-renesas/libraries/RTC/src/RTC.cpp
Lines 606 to 613 in 0e9f4df
but there's not a single
return
keyword in that function. It ought to doreturn is_initialized;
at the end.This incorrect code causes some compilers (arm-none-eabi-gcc 10.3.1) to emit assembly that causes an infinite loop. Any sketch using
RTC.begin();
deadlocks forever. Specifically, the assembly is(Notice how there is no
pop {..., pc}
to facilitate any returning in that function. After writingtrue
, the code immediately writesfalse
and jumps back to the beginingo of the code that writesfalse
, thus being stuck forever at that line of C++ code). When I fix the codeIt does nicely return.
This code is undefined behavior which does happpen to work on the compiler version used in the Arduino IDE (7.0.1), however, the higher version one used in PlatformIO (10.3.1) breaks with it. (We upgraded it because, what could possible go wrong? Well, this). And of course, if this core ever decides to upgrade its compiler, this unfixed code is a ticking timebomb.
The text was updated successfully, but these errors were encountered: