Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Segmentation Faults in Release Mode, Not in Debug (Read 3247 times)
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Segmentation Faults in Release Mode, Not in Debug
Jul 21st, 2019 at 4:35pm
Print Post  
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
Select All
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
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #1 - Jul 22nd, 2019 at 11:59am
Print Post  
Please follow the guide in the yellow box and post the output.

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


Posts: 240
Joined: Oct 19th, 2011
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #2 - Jul 22nd, 2019 at 2:47pm
Print Post  
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 Sad

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #3 - Jul 23rd, 2019 at 9:14am
Print Post  
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
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #4 - Jul 23rd, 2019 at 12:42pm
Print Post  
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?

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #5 - Jul 23rd, 2019 at 12:47pm
Print Post  
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
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #6 - Aug 3rd, 2019 at 10:43pm
Print Post  
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

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #7 - Aug 3rd, 2019 at 10:55pm
Print Post  
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
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #8 - Aug 3rd, 2019 at 10:55pm
Print Post  
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: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #9 - Aug 3rd, 2019 at 11:00pm
Print Post  
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
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #10 - Aug 4th, 2019 at 11:26am
Print Post  
Thanks for the update. Never happened to me. I google'd it Smiley
« Last Edit: Aug 4th, 2019 at 11:26am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Segmentation Faults in Release Mode, Not in Debug
Reply #11 - Aug 4th, 2019 at 12:53pm
Print Post  
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 TopicPrint