Compiler error: 'panic: runtime error: index out of range'

Hello,

I'm trying to compile code for a project that uses a ChipKIT board. The first time I compile, everything works great, but when I try to compile again with the exact same code, I get the following error:

Arduino: 1.6.13 (Mac OS X), Board: "OpenBCI 32"

panic: runtime error: index out of range

goroutine 1 [running]:
panic(0x1519c0, 0xc4200100a0)
   /usr/local/go/src/runtime/panic.go:500 +0x1a1
arduino.cc/builder.findIncludesUntilDone(0xc42006f500, 0xc4203aacc0, 0x151ce0, 0xc42035d680, 0xc4202d01b6, 0x8, 0x0, 0x0)
   /Users/jenkins/jenkins/workspace/arduino-builder-macosx/src/arduino.cc/builder/container_find_includes.go:321 +0x138f
arduino.cc/builder.(*ContainerFindIncludes).Run(0x244c58, 0xc42006f500, 0x41bc3c3c, 0x0)
   /Users/jenkins/jenkins/workspace/arduino-builder-macosx/src/arduino.cc/builder/container_find_includes.go:149 +0x5e4
arduino.cc/builder.runCommands(0xc42006f500, 0xc4201a9af8, 0x22, 0x22, 0x1, 0x0, 0x0)
   /Users/jenkins/jenkins/workspace/arduino-builder-macosx/src/arduino.cc/builder/builder.go:189 +0xcd
arduino.cc/builder.(*Builder).Run(0xc4201a9d48, 0xc42006f500, 0xc42003bda8, 0x15cc60)
   /Users/jenkins/jenkins/workspace/arduino-builder-macosx/src/arduino.cc/builder/builder.go:124 +0xb90
arduino.cc/builder.RunBuilder(0xc42006f500, 0xc42003bda8, 0x244c58)
   /Users/jenkins/jenkins/workspace/arduino-builder-macosx/src/arduino.cc/builder/builder.go:220 +0x35
main.main()
   /Users/jenkins/jenkins/workspace/arduino-builder-macosx/src/arduino.cc/arduino-builder/main.go:316 +0x912
/Applications/Arduino.app/Contents/Java/arduino-builder returned 2
Error compiling for board OpenBCI 32.

If I close the code window (not quit the IDE, but just close the window) and the reopen the sketch, I can compile again. But only once. I am using the library found here

and I'm running the DefaultBoard.ino sketch from the examples folder.

This problem was posted on the Digilent forum,

and I also reached out to ChipKIT
http://chipkit.net/forum/viewtopic.php?f=7&t=3753&p=15664#p15664

majenko was able to replicate the problem in 1.6.12 and 1.6.13. It seems that something was changed between 1.6.11 and 1.6.12 that is causing this compilation problem.

I have upgraded to Arduino 1.8.0, and the problem persists.
I have to close the IDE window (not shut down arduino entirely) and re-open the sketch in order to upload code again.

Any ideas on when this will be fixed?

I have occasionally looked into using the ChipKit uc32 for projects, but I keep finding the Arduino IDE or Digilent libraries in various states of disrepair. I was hoping to give it another shot for an upcoming project using a GPS board, but this compile tool chain bug is impressively annoying.

I get the exact same behavior as Eggplant, where the first compile works but the second+ fail. You can either reload the whole IDE or change boards (which seems to reset the error).

This issue was explored by majenko over at the ChipKit team and they've definitely isolated it to the Arduino IDE toolchain somewhere. Please have a look at their investigations and hopefully it will point someone to the right place to start fixing this issue:
http://chipkit.net/forum/viewtopic.php?f=7&t=3753&p=15659#p15659

The thread identifies this commit as the one to introduce the bug:

commit e9439c2c32ca6cf7c731dbc1402de3ae37435af9
Author: jenkins jenkins@jenkins.fablabtorino
Date: Fri Aug 26 19:19:46 2016 +0200

update arduino-builder to 1.3.21

Unfortunately, they don't really have a good approach to fixing up the arduino-builder code base, so please have a look.

Thank you for all of your efforts. I definitely enjoy working with the Arduino platform and am hoping to have more boards to work with in the future.