Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Segmentation Faults in Release Mode, Not in Debug (Read 448 times)
FrankP
Member
***
Offline



Posts: 108
Segmentation Faults in Release Mode, Not in Debug
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
 



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

Any thoughts?

TIA,

Frank
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10473
United Kingdom
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #1 - Jul 22nd, 2019 at 12:59pm
 
Please follow the guide in the yellow box and post the output.

Thanks
Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 108
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #2 - 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 Sad

Frank
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10473
United Kingdom
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #3 - 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.
Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 108
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #4 - 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?

Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10473
United Kingdom
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #5 - 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.
Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 108
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #6 - 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 Wink

Frank

Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10473
United Kingdom
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #7 - 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.
Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 108
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #8 - 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

Back to top
 
 
IP Logged
 
Bob Jones
Full Member
***
Offline



Posts: 207
Bellingham, WA
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #9 - 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
Back to top
 
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10473
United Kingdom
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #10 - Aug 4th, 2019 at 12:26pm
 
Thanks for the update. Never happened to me. I google'd it Smiley
Back to top
« Last Edit: Aug 4th, 2019 at 12:26pm by Visual Micro »  
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 108
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #11 - 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.  Grin;-)

Frank
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print