www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/14/21:46:24

Xref: news2.mv.net comp.os.msdos.djgpp:7282
From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Debugging woes...
Date: Wed, 14 Aug 1996 19:33:09 -0700
Organization: Three pounds of chaos and a pinch of salt
Lines: 33
Message-ID: <32128C65.70ED@cs.com>
References: <199608122312 DOT JAA05520 AT gbrmpa DOT gov DOT au> <4uqhi6$hn1 AT news DOT rwth-aachen DOT de>
NNTP-Posting-Host: ppp212.cs.com
Mime-Version: 1.0
To: Hans-Bernhard Broeker <broeker AT I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN>
CC: Leath Muller <leathm AT gbrmpa DOT gov DOT au>
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hans-Bernhard Broeker wrote:
> > Anyway, I can't seem to debug it, because when I run the program under
> > fsdb and single step, run etc the program, it runs fine!!!
> 
> ... which clearly indicates that you, like every C programmer
> sometimes does, managed to screw up the stack or heap management.
> Programs changing behaviour when run in a debugger typically do
> so because they use the values found in uninitialized storage.
> Be sure you initialize all variables before you use them. Additionally,
> you might want to compile with '-Wall' and look if any of the places
> where gcc warns you about 'value used before it is initialized' might
> be the culprit.

Another way to determine if your program is referencing or otherwise using
uninitialized memory is to include <crt0.h> and add the following line to
your global variables:

_crt0_startup_flags = _CRT0_FLAG_FILL_DEADBEAF;

This causes all memory to be initalized with 0xdeadbeaf when it is
allocated.  If you see any variables with this value (or a fragment of
it) then you are using uninitialized memory.  It's worked for me any
number of times.  :)

-- 
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>+ W+>++ N++ o+ K? w(---) O-
M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+ tv+() b+++ DI++ D++ G e(*)>++++
h!() !r !y+()
------END GEEK CODE BLOCK------

- Raw text -


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