-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Rebooting issue with variadic arguments, zero-pointer execution #5236
Comments
At first glance, the code looks sane. What does it print? Reboot does indeed suggest zero call or jump, so the call to "before" seems the most likely place for this. I assume that removing the va_pseudo call also prevents the issue from happening, which means that somehow the vararg function messes something up that prevents the before check from happening correctly. This sounds like a gcc/compiler issue. Did you try with both 1.6.9 and 1.6.10? (the latter has a newer gcc version)? Thanks for reducing the example, this is something that should be reproducible from here (no Arduino around to try now, though). |
This is the serial output with both, Arduino 1.6.9 and 1.6.10: #define issue:
//#define issue:
|
ASM output: #define issue:
//#define issue:
Where it goes wrong is here:
vs
The zero check |
Agreed on your analysis, the zero check is indeed needed to let I'm not sure if it's related (I don't think so), but you are using This looks like a compiler bug to me. Could you perhaps reduce the testcase further (removing the serial prints) and compile it on its own with avr-gcc (without including any of the Arduino code)? If the problem then still occurs (from looking at the asm), this is something we can report to the gcc folks. Also, could you try compiling with gcc 5, I think a build should be available here: #660 (comment) Also, could you try building with lto disabled in 1.6.10? That means removing the -flto flags from |
I've transferred the example to Atmel studio, removed all Arduino code and using only the m328p led as indicator. Compiler avr-gcc 4.8.1, settings: Size optimisation -Os This is the code:
#define issue, ASM (led off):
//#define issue, ASM (led on)
** surprisingly, disabling size optimisation (i.e. -O0) solves the issue: #define issue, ASM (led on):
//#define issue, ASM (led on):
See
in both scenarios
vs.
avr-gcc 5.1.0 shows a similar behavior with -Os, however, this issue seems resolved in 6.1.0 |
Thanks for further minimizing. It seems I missed your later comments, since no notification is sent when you edit a comment (so best not do that when you add significant info). I've reproduced your issue and slightly minimized it further, and submitte it upstream here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77326 You say it is resolved in 6.1.0. Did you compile that yourself, or is there source of prebuilt (Linux?) binaries of avr-gcc? I couldn't find any just now (for Debian / generic Linux). |
I've found some win binaries here: http://blog.zakkemble.co.uk/avr-gcc-6-1-0/ |
Upstream fixed this issue (see the bug report for details), indicating it is fixed in 6.3+ and backported to 5.5+. I'm closing this issue, as there isn't much Arduino can do at this point, other than upgrade to a newer version when Atmel updates its patches. |
AVR crashes / reboots with this sketch, asm hints to a zero-pointer call.
The text was updated successfully, but these errors were encountered: