HELP! Arduino not compiling my code! [Solved]

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino Leonardo"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\CDC.cpp: In member function 'available':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\CDC.cpp:187:1: internal compiler error: Segmentation fault

 }

 ^

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://gcc.gnu.org/bugs.html> for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Leonardo.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Yea… So it turns out that Arduino doesn’t like me anymore. I was just casually writing code for my port of the Snake Game (My version is called SnakeBoy) when I tried compiling it and it just spat that error message back right at my face. Any help would be great, and if you need more information, just ask me.

An internal segfault could have been caused by a lot of things,
it’s nearly impossible to guess or pinpoint an exact cause without the code that caused it.
(9 times out of 10 ‘segfault’ actually means ‘attempt to dereference null pointer’.)

You could try using the regular version of the Arduino IDE instead of the Windows Store version (I know this has causes issues for some people in the past) but I can’t say how likely that is to be the cause.

I know for definite that I’ve had the compiler segfault before, but I can’t remember why.
(Knowing me I was probably doing something crazy.)

You could also try turning on verbose compilation output in case the longer compilation message reveals anything useful.

1 Like

as the log suggest, check the show verbose output during compilation in preferences for more information.

The segmentation fault may be caused by another error that currently isn’t logged.

I turned on show verbose, and this is the error message I got.

And here is the code, as requested.

Hope this helps!

It’s probably a really dumb mistake that just flew straight over my head, though.
:wink:

That’s not all the code, there’s still two files missing.

Already I can spot one mistake.
delay is designed to take a number of milliseconds as an integer,
so at the moment delay(3.59375); is being treated as if it were delay(3); (3 milliseconds).

I doubt that’s relevant to the crash though.

Sorry, here is Audio.h, and here is Images.h. I didn’t make any changes to it before it stopped working, though. Also, the delay timing is just me being precise. :wink:

Oh, and I have been uploading other code, and it works just fine. The other code, that is.

Never mind, I just worked out the problem… kind of. Turns out that at line 48 in SnakeBoy.ino, I wrote arduboy.drawRect(...); instead of arduboy.fillRect(...);. I don’t see why that could of caused the error, though. Could someone please explain this?

Probably totally unrelated.

I quite often get the segmentation fault on my Win10 machine but have never had it on my Mac. On the Windows machine, I can often make a simple change and it will recompile properly.

And just an F.Y.I.:
For delays less than 65 seconds you can use arduboy.delayShort() in place of Arduino delay() to save a few bytes of code.