VS Arduino
>> >> Segmentation Faults in Release Mode, Not in Debug
https://www.visualmicro.com/forums/YaBB.pl?num=1563726935

Message started by FrankP on Jul 21st, 2019 at 4:35pm

Title: Segmentation Faults in Release Mode, Not in Debug
Post by FrankP on Jul 21st, 2019 at 4:35pm
I have a program I have been using for quite a while, and suddenly it started throwing segmentation faults in 'NewPing.cpp'.  After some experimentation, I discovered that it compiled fine in DEBUG mode, but not in RELEASE mode.  I normally work in DEBUG mode, but apparently I inadvertently switched to RELEASE mode and started seeing the errors.  The error is:

[code]NewPing.cpp: In member function __base_ctor .constprop

NewPing.cpp:42: internal compiler error  Segmentation fault

Error linking for board Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)
   Please submit a full bug report
Build failed for project 'TwoWheelRobot'
   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]

I have included the verbose output files for both the RELEASE and DEBUG cases

Any thoughts?

TIA,

Frank

https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=190721_TwoWheelRobot_VS_Debug.txt ( 105 KB | 2 Downloads )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=190721_TwoWheelRobot_VS_Release.txt ( 16 KB | 2 Downloads )

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by Visual Micro on Jul 22nd, 2019 at 11:59am
Please follow the guide in the yellow box and post the output.

Thanks

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by FrankP on Jul 22nd, 2019 at 2:47pm

Tim@Visual Micro wrote on Jul 22nd, 2019 at 11:59am:
Please follow the guide in the yellow box and post the output.

Thanks


Tim,

Sorry - can't get it to fail any more.  Don't know what changed, but now everything compiles both in RELEASE and DEBUG mode :-(

Frank

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by Visual Micro on Jul 23rd, 2019 at 9:14am
I think you just hit a magic number on the program size. It's a know issue for arduino.

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by FrankP on Jul 23rd, 2019 at 12:42pm

Tim@Visual Micro wrote on Jul 23rd, 2019 at 9:14am:
I think you just hit a magic number on the program size. It's a know issue for arduino.



Hmm, but does that explain why it compiled OK in the Arduino IDE?


Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by Visual Micro on Jul 23rd, 2019 at 12:47pm
We would have to compare the arduino verbose output. It's possible that we have slightly different size with some additional defines.

In the latest versions of visual micro the Build>Clean also cleans the tool chain cache so if it happens again so that then full build with verbose and show build properties will help alongside the arduino verbose output.

Bear in mind that we just run external programs to run a build so it's easy to replicate and cleat to see in the output. There isn't any magic behind the scenes that is not in the output.

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by FrankP on Aug 3rd, 2019 at 10:43pm
Tim,

Happening again for me; DEBUG compile fails in VS2017/VM (verbose compile/build output attached).  Compiles and uploads OK in Arduino IDE (verbose compile/build output attached).

Let me know if you find anything ;-)

Frank


https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=190803_VMicroCompile.txt ( 60 KB | 2 Downloads )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=190803_ArduinoCompile.txt ( 15 KB | 2 Downloads )

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by Visual Micro on Aug 3rd, 2019 at 10:55pm
To make comparison with the Arduino ICDE please switch Visual Micro to Release mode and then post the output.

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by FrankP on Aug 3rd, 2019 at 10:55pm
may have been another 'magic number'.  Made an inconsequential edit to the code and now it compiles/uploads again

Frank


Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by Bob Jones on Aug 3rd, 2019 at 11:00pm
Frank,

Your experience mirrors mine. The segmentation faults are really almost random. Move one line of code around and it goes away for a minute, hour, or longer. Then make another innocuous change and it is back.

I have almost resigned myself to the reality that this is a bug that can only be cured by throwing out the current compiler and getting a new one... but I have no idea how to go about that. I have heard rumors of a new compiler emerging but can't remember its name or status.

Bob Jones

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by Visual Micro on Aug 4th, 2019 at 11:26am
Thanks for the update. Never happened to me. I google'd it :)

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by FrankP on Aug 4th, 2019 at 12:53pm
It's a corollary to Murphy's law.  If something can go wrong - it will go wrong, but only to users.  ;D;-)

Frank

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.