Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
Visual Micro >> Visual Studio 2017, 2019 >> 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 5:35pm

Title: Segmentation Faults in Release Mode, Not in Debug
Post by FrankP on Jul 21st, 2019 at 5: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 | 4 )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=190721_TwoWheelRobot_VS_Release.txt (16 KB | 5 )

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by Visual Micro on Jul 22nd, 2019 at 12:59pm
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 3:47pm

Visual Micro wrote on Jul 22nd, 2019 at 12:59pm:
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 10: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 1:42pm

Visual Micro wrote on Jul 23rd, 2019 at 10: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 1: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 11: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 | 3 )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=190803_ArduinoCompile.txt (15 KB | 3 )

Title: Re: Segmentation Faults in Release Mode, Not in Debug
Post by Visual Micro on Aug 3rd, 2019 at 11: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 11: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 4th, 2019 at 12:00am
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 12:26pm
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 1:53pm
It's a corollary to Murphy's law.  If something can go wrong - it will go wrong, but only to users.  ;D;-)

Frank

Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2019. All Rights Reserved.