Skip to content

IDE 1.8.6 - SD-Lib "Datalogger" - segmentation fault #7949

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

Closed
mikrocoder opened this issue Aug 29, 2018 · 25 comments
Closed

IDE 1.8.6 - SD-Lib "Datalogger" - segmentation fault #7949

mikrocoder opened this issue Aug 29, 2018 · 25 comments
Labels
Component: Compilation Related to compilation of Arduino sketches OS: Windows Specific to the Windows version of the Arduino IDE

Comments

@mikrocoder
Copy link

mikrocoder commented Aug 29, 2018

Hallo,

I have the following sporadic error. Memory is checked with Memtest and okay.
If I copy the sketch into a new window, no errors will occur.
With the older SD-Lib version of IDE 1.8.5 compiles without errors under the new IDE 1.8.6
Windows 10 64Bit

Arduino: 1.8.6 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Worker\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Worker\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Worker\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10806 -build-path C:\Users\Worker\AppData\Local\Temp\arduino_build_196433 -warnings=all -build-cache C:\Users\Worker\AppData\Local\Temp\arduino_cache_166815 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Program Files (x86)\Arduino\libraries\SD\examples\Datalogger\Datalogger.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Worker\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Worker\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Worker\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10806 -build-path C:\Users\Worker\AppData\Local\Temp\arduino_build_196433 -warnings=all -build-cache C:\Users\Worker\AppData\Local\Temp\arduino_cache_166815 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Program Files (x86)\Arduino\libraries\SD\examples\Datalogger\Datalogger.ino
Using board 'mega' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10806 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\sketch\\Datalogger.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10806 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\sketch\\Datalogger.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10806 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\SD\\src" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\sketch\\Datalogger.ino.cpp" -o nul
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src\SPI.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\libraries\SD\src\File.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\libraries\SD\src\SD.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\libraries\SD\src\utility\Sd2Card.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdVolume.cpp
Generating function prototypes...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10806 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\SD\\src" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\sketch\\Datalogger.ino.cpp" -o "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Sketch wird kompiliert...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10806 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\SD\\src" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\sketch\\Datalogger.ino.cpp" -o "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\sketch\\Datalogger.ino.cpp.o"
Compiling libraries...
Compiling library "SPI"
Zuvor kompilierte Datei wird verwendet: C:\Users\Worker\AppData\Local\Temp\arduino_build_196433\libraries\SPI\SPI.cpp.o
Compiling library "SD"
Zuvor kompilierte Datei wird verwendet: C:\Users\Worker\AppData\Local\Temp\arduino_build_196433\libraries\SD\File.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\Worker\AppData\Local\Temp\arduino_build_196433\libraries\SD\SD.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\Worker\AppData\Local\Temp\arduino_build_196433\libraries\SD\utility\Sd2Card.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\Worker\AppData\Local\Temp\arduino_build_196433\libraries\SD\utility\SdFile.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\Worker\AppData\Local\Temp\arduino_build_196433\libraries\SD\utility\SdVolume.cpp.o
Compiling core...
Using precompiled core: C:\Users\Worker\AppData\Local\Temp\arduino_cache_166815\core\core_arduino_avr_mega_cpu_atmega2560_0c812875ac70eb4a9b385d8fb077f54c.a
Linking everything together...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433/Datalogger.ino.elf" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\sketch\\Datalogger.ino.cpp.o" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\libraries\\SPI\\SPI.cpp.o" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\libraries\\SD\\File.cpp.o" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\libraries\\SD\\SD.cpp.o" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\libraries\\SD\\utility\\Sd2Card.cpp.o" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\libraries\\SD\\utility\\SdFile.cpp.o" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433\\libraries\\SD\\utility\\SdVolume.cpp.o" "C:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433/..\\arduino_cache_166815\\core\\core_arduino_avr_mega_cpu_atmega2560_0c812875ac70eb4a9b385d8fb077f54c.a" "-LC:\\Users\\Worker\\AppData\\Local\\Temp\\arduino_build_196433" -lm
In function 'global constructors keyed to 65535_0_Datalogger.ino.cpp.o':

lto1.exe: 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 (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files (x86)/arduino/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

Bibliothek SPI in Version 1.0 im Ordner: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI  wird verwendet
Bibliothek SD in Version 1.2.2 im Ordner: C:\Program Files (x86)\Arduino\libraries\SD  wird verwendet
exit status 1
Fehler beim Kompilieren für das Board Arduino/Genuino Mega or Mega 2560.
@per1234
Copy link
Collaborator

per1234 commented Aug 29, 2018

A previous "Segmentation fault" issue report:
#7946

I've also encountered sporadic errors similar to this while using the Arduino AVR Boards 1.6.20x beta releases. I was never able to produce a MCVE. The problem would go away after I restarted my computer. The problem did not occur when the same code was compiled with Arduino AVR Boards 1.6.21.

@per1234 per1234 added the Component: Compilation Related to compilation of Arduino sketches label Aug 30, 2018
@mikrocoder
Copy link
Author

mikrocoder commented Sep 5, 2018

I have switched back to version v1.8.5 now.
I hope it is fixed in the next version.

@PaulStoffregen
Copy link
Contributor

I tried it just now on Windows 10 64 bit with Arduino 1.8.6 using AVR core 1.6.22.

Clicked Verify a dozen times. All worked perfectly.

capture

@mikrocoder
Copy link
Author

mikrocoder commented Sep 5, 2018

I can't say otherwise how it is. v1.8.5 works without errors and 1.8.6 with sporadic errors with this example. I've never had a segmentation error before. Possibly a rare error in the new toolchain version. I'm also not the only one with the segmentation fault problem. https://forum.arduino.cc/index.php?topic=566826.0

Additional question. Why is the variable pathidx not initialized in SD.cpp?

@qbahn21
Copy link

qbahn21 commented Sep 19, 2018

Confirm. I've also experienced such a sporadic errors with 1.8.6 toolchain. 1.8.5 works great!

@per1234
Copy link
Collaborator

per1234 commented Nov 29, 2018

I'm going to start a list of the reports of this issue in case it helps with the investigation:

In all cases, the OS is Windows.

I'll continue to add to the list as additional reports come in.

@per1234 per1234 added the OS: Windows Specific to the Windows version of the Arduino IDE label Nov 29, 2018
@facchinm
Copy link
Member

@per1234 I'm investigating the issue by bisecting Atmel patches and vanilla gcc versions. It could take a bit. Reproducing consistently on all OSes with this sketch arduino/ArduinoCore-avr#39 (when that will be fixed I think also this issue could be automatically solved).

@facchinm
Copy link
Member

facchinm commented Nov 29, 2018

Here's a json ready for testing for all host OS (http://downloads.arduino.cc/packages/package_avr_7.3.0_index.json). It will trigger an update to avr core 1.6.208.

The build is based on vanilla gcc since Atmel patches for 5.4.0 break an internal sanity test when finalizing the build (didn't have the time to try to fix it yet). The missing Atmel patches are likely to break or limit support for ATTiny so DON'T USE THIS THING IN PRODUCTION 😄

However, all other boards should be supported (avr4809 too). This toolchain fixes arduino/ArduinoCore-avr#39 while I couldn't reproduce #7949 so I hope you can test it and report back.

@matthijskooijman do you still have the mass builder script with all the fancy statistics lying around? It would be cool to have a 4.9.2 vs 5.4.0 vs 7.3.0 😉

EDIT: avr4809 (architecture avrxmega3) support needs Atmel patches, so right now the toolchain is just suitable fol classic ATMegas.

@mikrocoder
Copy link
Author

I have tested ArduinoCore version 1.6.23.
https://github.com/arduino/ArduinoCore-avr
and then compiled the Sketch SD-Datalogger countless times.
No segemantation errors so far. 👍

@matthijskooijman
Copy link
Collaborator

@facchinm, Nice to see a vanilla gcc. If we can get that to work (possibly with some patches applied upstream), that would totally rock over having to wait for atmel all the time :-)

As for the builder script, it's here: https://github.com/matthijskooijman/arduino-mass-builder
I haven't used it anymore since I first wrote it, but I suspect it still works :-)

@facchinm
Copy link
Member

facchinm commented Dec 3, 2018

I've just updated the toolchain to arduino4 with all (I hope 🙂 ) the Atmel patches included. AVR core gets updated to .209 ; compiling for 4809 is now possible, although the megaAVR core needs an extra patch (the toolchain version in use is hardcoded in platform.txt).
@matthijskooijman I'll launch the mass builder soon, thanks for the link 😉

Patches here: https://github.com/arduino/toolchain-avr/tree/staging/avr-gcc-patches

@per1234
Copy link
Collaborator

per1234 commented Dec 3, 2018

I've been hoping to check whether the new toolchain fixes the segmentation fault but I haven't been able to reproduce that bug even with Arduino AVR Boards 1.6.23, despite compiling multiple sketches that have caused it for me in the past on and off. It's really a pain of a bug.

I have been using Arduino AVR Boards 1.6.208 (and now 1.6.209) with no problems since it was published. I'll be sure to report if I discover anything of note.

@mikrocoder
Copy link
Author

I tested the datalogger example with IDE v1.8.8, couldn't provoke a segmentation error. :-)

@ImpulseAdventure
Copy link

Another validation datapoint: I had reported a similar crash with lto, gcc 5.4.0 & Windows in arduino/ArduinoCore-avr#55.

@facchinm -- upon retesting with the revised package json with AVR boards 1.6.208 & IDE 1.8.7, I'm happy to report that I no longer observe the compiler crash.

As a reference for others, here is the simple testcase I constructed for the bug, using a couple structs and an extern "C" wrapper: https://github.com/ImpulseAdventure/Arduino-LTO-Error

@Psychokiller1888
Copy link

Same here, randomly happens. Since today impossible to compile at all anymore, where I could sporadically compile before

Stanimir-Petev added a commit to OLIMEX/Arduino_configurations that referenced this issue Jan 10, 2019
This version is recommended with Arduino 1.8.8 or newer due to some issues with the new compiler on older versions: arduino/Arduino#7949.
Updated AVR-GCC compiler (5.4.0-atmel3.6.1-arduino2) and AVRdude uploader (6.3.0-arduino14) with the latest for the moment.
Changed some flags and options into platform.txt.
Added support and example sketches for Olimex board eduArdu.
@paynterf
Copy link

paynterf commented Feb 10, 2019

Same problem with V1.8.7 on Windows 10 home edition.

Compiling debug version of 'StepperSpeedCtrl' for 'Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)'
Build Folder: "file:///C:/Users/Frank/AppData/Local/Temp/VMBuilds/StepperSpeedCtrl/mega_atmega2560/Debug"
Additional Defines: VM_DEBUG;VM_DEBUG_ENABLE 1;VM_DEBUG_BANDWIDTH_THROTTLE_MS 50;VM_DEBUGGER_TYPE_HARDWARESERIAL 0;VM_DEBUGGER_TYPE_SOFTWARESERIAL 1;VM_DEBUGGER_TYPE_FASTSERIAL 2;VM_DEBUGGER_TYPE_USB 3;VM_DEBUGGER_TYPE_TEENSY 4;VM_DEBUGGER_TYPE_UART 5;VM_DEBUGGER_TYPE_USART 6;VM_DEBUGGER_TYPE_USBSERIAL 7;VM_DEBUGGER_TYPE_TTYUART 8;VM_DEBUGGER_TYPE_NET_CONSOLE 9;VM_DEBUGGER_TYPE_Uart 10;VM_DEBUGGER_TYPE_COSA 11;VM_DEBUGGER_TYPE_CDCSerialClass 12;VM_DEBUGGER_TYPE_HARDWARESERIAL1 13;VM_DEBUGGER_TYPE_HARDWARESERIAL2 14;VM_DEBUGGER_TYPE_HARDWARESERIAL3 15;VM_DEBUGGER_TYPE_NET_UDP 16;VM_DEBUGGER_TYPE_USBAPI 17;VM_DEBUGGER_TYPE_SERIALUSB 18;VM_DEBUGGER_TYPE_MS430_SERIAL_ 19;VM_DEBUGGER_TYPE VM_DEBUGGER_TYPE_HARDWARESERIAL;VM_DEBUG_BREAKPAUSE;
Architecture Tools: "file:///C:/Program%20Files%20(x86)/Arduino/hardware/tools/avr/bin/"
Api: 1221
Sketch Book: "file:///C:/Users/Frank/Documents/Arduino"
Sketch Include Paths
Core Include Paths
Include Path "file:///C:/Program%20Files%20(x86)/Arduino/hardware/arduino/avr/cores/arduino"
Include Path "file:///C:/Program%20Files%20(x86)/Arduino/hardware/arduino/avr/variants/mega"
 
Deep search for libraries ...
Using previous search results: C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug\StepperSpeedCtrl.cpp
Using previous search results: C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug\StepperSpeedCtrl.cpp
Using previous search results: C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug\StepperSpeedCtrl.cpp
Using previous search results: C:\Program Files (x86)\Arduino\libraries\Stepper\src\Stepper.cpp
"C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DVM_DEBUG_BREAKPAUSE -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUGGER_TYPE_MS430_SERIAL_=19 -DVM_DEBUGGER_TYPE_SERIALUSB=18 -DVM_DEBUGGER_TYPE_USBAPI=17 -DVM_DEBUGGER_TYPE_NET_UDP=16 -DVM_DEBUGGER_TYPE_HARDWARESERIAL3=15 -DVM_DEBUGGER_TYPE_HARDWARESERIAL2=14 -DVM_DEBUGGER_TYPE_HARDWARESERIAL1=13 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=50 -DVM_DEBUG_ENABLE=1 -DVM_DEBUG   -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Program Files (x86)\Arduino\libraries\Stepper\src" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG\utility" "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG\VM_DBG.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DVM_DEBUG_BREAKPAUSE -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUGGER_TYPE_MS430_SERIAL_=19 -DVM_DEBUGGER_TYPE_SERIALUSB=18 -DVM_DEBUGGER_TYPE_USBAPI=17 -DVM_DEBUGGER_TYPE_NET_UDP=16 -DVM_DEBUGGER_TYPE_HARDWARESERIAL3=15 -DVM_DEBUGGER_TYPE_HARDWARESERIAL2=14 -DVM_DEBUGGER_TYPE_HARDWARESERIAL1=13 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=50 -DVM_DEBUG_ENABLE=1 -DVM_DEBUG   -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Program Files (x86)\Arduino\libraries\Stepper\src" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG\utility" "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG\VM_mem_check.c" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DVM_DEBUG_BREAKPAUSE -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUGGER_TYPE_MS430_SERIAL_=19 -DVM_DEBUGGER_TYPE_SERIALUSB=18 -DVM_DEBUGGER_TYPE_USBAPI=17 -DVM_DEBUGGER_TYPE_NET_UDP=16 -DVM_DEBUGGER_TYPE_HARDWARESERIAL3=15 -DVM_DEBUGGER_TYPE_HARDWARESERIAL2=14 -DVM_DEBUGGER_TYPE_HARDWARESERIAL1=13 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=50 -DVM_DEBUG_ENABLE=1 -DVM_DEBUG   -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Program Files (x86)\Arduino\libraries\Stepper\src" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG\utility" "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG\VM_mem_check_sam.cpp" -o "nul"
 
Building variant ...
 
  Using previously compiled variant
 
Building core ...
 
Building libraries ...

Using library Stepper version 1.1.3 in folder "file:///C:/Program%20Files%20(x86)/Arduino/libraries/Stepper"
  Using previously compiled file: C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug\Stepper\Stepper.cpp.o
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DVM_DEBUG_BREAKPAUSE -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUGGER_TYPE_MS430_SERIAL_=19 -DVM_DEBUGGER_TYPE_SERIALUSB=18 -DVM_DEBUGGER_TYPE_USBAPI=17 -DVM_DEBUGGER_TYPE_NET_UDP=16 -DVM_DEBUGGER_TYPE_HARDWARESERIAL3=15 -DVM_DEBUGGER_TYPE_HARDWARESERIAL2=14 -DVM_DEBUGGER_TYPE_HARDWARESERIAL1=13 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=50 -DVM_DEBUG_ENABLE=1 -DVM_DEBUG -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Program Files (x86)\Arduino\libraries\Stepper\src" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Arduino\libraries" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Users\Frank\Documents\Arduino\libraries" "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG\VM_DBG.cpp" -o "C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug\VM_DBG\VM_DBG.cpp.o"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DVM_DEBUG_BREAKPAUSE -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUGGER_TYPE_MS430_SERIAL_=19 -DVM_DEBUGGER_TYPE_SERIALUSB=18 -DVM_DEBUGGER_TYPE_USBAPI=17 -DVM_DEBUGGER_TYPE_NET_UDP=16 -DVM_DEBUGGER_TYPE_HARDWARESERIAL3=15 -DVM_DEBUGGER_TYPE_HARDWARESERIAL2=14 -DVM_DEBUGGER_TYPE_HARDWARESERIAL1=13 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=50 -DVM_DEBUG_ENABLE=1 -DVM_DEBUG -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Program Files (x86)\Arduino\libraries\Stepper\src" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Arduino\libraries" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Users\Frank\Documents\Arduino\libraries" "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\sivbitce.zrh\Micro Platforms\default\debuggers\VM_DBG\VM_mem_check_sam.cpp" -o "C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug\VM_DBG\VM_mem_check_sam.cpp.o"
 
Building project code ...
  Using previously compiled file: C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug\StepperSpeedCtrl.cpp.o
 
Linking it all together ...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc" -Wall -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug/StepperSpeedCtrl.ino.elf" "StepperSpeedCtrl.cpp.o" "Stepper\Stepper.cpp.o" "VM_DBG\VM_DBG.cpp.o" "VM_DBG\VM_mem_check_sam.cpp.o" "C:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug/core.a" "-LC:\Users\Frank\AppData\Local\Temp\VMBuilds\StepperSpeedCtrl\mega_atmega2560\Debug" -lm
 
   In function global constructors keyed to 65535_0_StepperSpeedCtrl.cpp.o
 
lto1.exe*: internal compiler error: Segmentation fault

Error linking for board Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)
Debug build failed for project 'StepperSpeedCtrl'
   Please submit a full bug report
   with preprocessed source if appropriate
   gcc.gnu.org\bugs.html> for instructions
 
lto-wrapper.exe*: fatal error: C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-gcc returned 1 exit status
   compilation terminated
 
ld.exe: error: lto-wrapper failed
 
collect2.exe*: error: ld returned 1 exit status

Code:

/*
    Name:       StepperSpeedCtrl.ino
    Created:	1/28/2019 9:29:19 AM
    Author:     FRANKWIN10\Frank
*/


#include <Stepper.h>


const int stepsPerRevolution = 200;// change this for your motor
const int SPEED_CONTROL_PIN = A9; //center pin of the potentiometer goes here
const int MAX_MOTOR_RPM = 100; //max you want the motor to go with pot all the way up
const int MIN_MOTOR_RPM = 0; //min you want the motor to go with the pot all the way down
const int MAX_ANALOG_VALUE = 1023; //normal for 8-bit A/D, but can be higher
const int MIN_ANALOG_VALUE = 0; //normal, but some systems might be different

// initialize the stepper library on pins 8 through 11 - any set of digital pins will do
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
//Stepper myStepper(stepsPerRevolution, 2, 3, 4, 5);  //used for Uno, I think

int defaultscanSpeedRpm = 6;  //the starting speed value
int numloops = 0; //used to display speed-related parameters
const int DISPLAY_LOOP_COUNT = 10; //how many loops to skip between prints



void setup() 
{
	Serial.begin(115200);  //start the serial port
	delay(2500); //needed for Teensy

	//setup the analog pin used for potentiometer speed control input
	pinMode(SPEED_CONTROL_PIN, INPUT);  //configure the A0 pin as input

}


void loop()
{
	int potval = analogRead(SPEED_CONTROL_PIN);//Get the pot value (0-1023)

	//now compute the ratio of the actual pot value to range of values  (need (float) here or you'll always get zero)
	float potratio = (float)(potval - MIN_ANALOG_VALUE) / (float)(MAX_ANALOG_VALUE - MIN_ANALOG_VALUE);

	//now covert this ratio to an RPM value between MIN and MAX
	float rpm = potratio * (MAX_MOTOR_RPM - MIN_MOTOR_RPM);


////DEBUG!! //can comment this out after everything is working
	if (numloops >= DISPLAY_LOOP_COUNT)
	{
		numloops = 0;
		Serial.print("potval, potratio, rpm = "); Serial.print(potval); Serial.print(", "); 
		Serial.print(potratio); Serial.print(", "); Serial.println(rpm);
	}
////DEBUG!!

	//adjust this value and the number of steps below to get the best stepper performance
	//delay(500);  //2 readings per sec to start
	//delay(100); 
	delay(50);  

	//now set the motor speed and move some steps.  Too many steps and it won't be responsive
	//to speed changes.  Too few and it will be too choppy.
	myStepper.setSpeed(rpm);
	myStepper.step(10);
	numloops++;
}

Might be code-length dependent. I couldn't get it to fail with the Blink sketch, failed about 1 out of 5 with this sketch, and 8/10 on my 3K+ line sketch

Just started happening yesterday and today. Not sure why.

@ImpulseAdventure
Copy link

ImpulseAdventure commented May 15, 2019

FYI @facchinm & @per1234 -- in case it is helpful to have a very minimal test sketch to reproduce the LTO failure in IDE 1.8.9 w/o any other dependencies, please see: Arduino-LTO-Error.

For the benefit of others looking for a solution (without rolling back to an older version):

  • The workaround of installing package_avr_7.3.0_index.json with latest Arduino AVR Boards (1.6.209) resolves the issue:
    • Add http://downloads.arduino.cc/packages/package_avr_7.3.0_index.json to the Preferences -> Settings -> Additional Boards Manager URLs
    • In Tools -> Board -> Boards Manager, locate Arduino AVR Boards and click on Update. This should be reflected as version 1.6.209.
    • Note that it was cautioned earlier that this workaround is not intended for production.
    • Special thanks to per1234 for identifying occurrences of the issue in various repos and highlighting the workarounds

@MartyMacGyver
Copy link

It's been just over a year now. Is anyone officially working on this issue so it can be resolved in the main Arduino toolchain versus the "don't use in production" workarounds?

@mikrocoder
Copy link
Author

Well, guys, I wasn't taken seriously back then. Neither here nor in the Arduino Forum. Can only say uses a current toolchain.

@MartyMacGyver
Copy link

@mikrocoder Looks like that's changed now - give 1.8.10 a try, and be sure to update your board compilers via the boards manager.

@ImpulseAdventure
Copy link

ImpulseAdventure commented Sep 21, 2019

Fantastic! Arduino IDE 1.8.10 (with Arduino AVR Boards 1.8.1) appears to have resolved the LTO issues I had previously observed in my testcases.

@facchinm & the rest of the Arduino team -- thank you very much for the fix!

@mikrocoder
Copy link
Author

Nice. I'm about to test it. What was fixed is unfortunately not in the release note. Although I now use a current toolchain.

@MartyMacGyver
Copy link

MartyMacGyver commented Sep 21, 2019

You need to download the latest board package via the boards manager after the install, but it's from the official source now, isn't it? Or does it depend on the alternate source still?

@facchinm
Copy link
Member

@MartyMacGyver it's official now; the relevant part of the changelog is here (should backport to avr repo)

@MartyMacGyver
Copy link

Great news! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Compilation Related to compilation of Arduino sketches OS: Windows Specific to the Windows version of the Arduino IDE
Projects
None yet
Development

No branches or pull requests

10 participants