delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/02/11/01:05:06

Date: Tue, 11 Feb 2003 08:01:52 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
Subject: Re: Checking for stack overflow
In-Reply-To: <3E47CDCC.9330D67E@yahoo.com>
Message-ID: <Pine.SUN.3.91.1030211075706.25449B-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 10 Feb 2003, CBFalconer wrote:

> > Assuming that esp
> > has already decremented to point to the newly allocated space,
> > the possible overflow is detected thus:
> 
> I don't believe you should make any such assumption.  You cannot
> assume that anything called has stack checking code.

I think you misunderstood what Esa was saying (or else I misunderstood
it ;-).  As I understand it, his code assumes to be called by GCC _after_ 
each change in ESP.  There's no assumption that the calling code was 
compiled with stack checking. 

> So I
> consider you should ONLY check at function entry, when stack space
> is being allocated for locals.

If I understand correctly, here you assume that the code generated by the 
compiler allocates space for locals only in the function prologue.  This 
is not true for latest versions of GCC, especially under -On optimization 
options.  Take a look at the code it emits, search for "esp", and you 
will see how many stack adjustments are done during a function's life.

- Raw text -


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