delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/06/02/01:55:34

Date: Sun, 2 Jun 2002 08:21:12 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp AT delorie DOT com
Subject: Re: HELP -- how do I fix this?
In-Reply-To: <3cf83647$1_4@news.meganetnews.com>
Message-ID: <Pine.SUN.3.91.1020602081545.10047G-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 31 May 2002, S.Turner wrote:

> Rhide says: "Program has received signal: SIGSEGV, Segmentation fault"
> 
> So, I reverted back to a know working back up of the source code and have come 
> to find
> out that if I step through the program one line at a time (using RHIDE) that-- 
> well, 
> according to RHIDE, the program executes lines of code out of order.

This is normal: the compiler optimizes your code, and as part of this 
optimization moves code around.  It's a bit confusing at first, but it's 
not too hard to get used to.

If you want to avoid this reordering, compile without optimizations.  But 
please be aware that doing so produces code that is very different from 
optimized code, so you are in fact debugging a different program.  In 
particular, the bug which causes the crash might not even happen if you 
compile without optimizations.

So on balance, I'd suggest to leave optimizations enabled and get used to 
the execution jumps.

> The actual crash appears to be coming from a mishandled character array but I 
> cannot see
> how this is happening with this erratic debugging.

You should concentrate on the line that is shown as current when the 
array is mishandled.  If you cannot figure that out, post here the 
relevant code fragment and what you see in RHIDE as far as the values of 
related variables are concerned, and someone will help you.

> The final oddity is that the .EXE file itself when run at the DOS prompt will 
> run to 
> completion without any problems.

This is a sign of using uninitialized memory.  When you run a program 
under RHIDE, it uses a different memory region, and thus a different 
random garbage.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019