delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/30/19:38:29

Message-ID: <cfalCTBApoy3EwWV@xemu.demon.co.uk>
Date: Mon, 30 Aug 1999 14:42:24 +0100
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Cc: djgpp AT delorie DOT com
From: Dave Bird <dave AT xemu DOT demon DOT co DOT uk>
Subject: Re: Error General Fault Protection on quit???
References: <$QodhXALbXy3EwjC AT xemu DOT demon DOT co DOT uk>
<Pine DOT SUN DOT 3 DOT 91 DOT 990830094206 DOT 3558B-100000 AT is>
In-Reply-To: <Pine.SUN.3.91.990830094206.3558B-100000@is>
MIME-Version: 1.0
X-Mailer: Turnpike (32) Version 4.01 <dQumtnY$x4rJ2u5tL5fS$n2vuP>
Reply-To: djgpp AT delorie DOT com

In message <Pine DOT SUN DOT 3 DOT 91 DOT 990830094206 DOT 3558B-100000 AT is>, Eli Zaretskii
<eliz AT is DOT elta DOT co DOT il> writes
>>  I don't know whether it is possible to right a function which
>>  tests for an invalid pointer without bombing.
>
>How about this (UNTESTED)?
>
>   void validate_or_die (void *ptr)
>   {
>     if ( (unsigned)p < 0x1000)
>       abort ();
>   }

 Sounds possible... I'd prefer to log or report rather than abort,
 and is there an upper limit?? Also to have it as a test you could put,
 at least at infrequently used gateways.  Also to report IP
 and pointer variable used, which helps if it's in some static or auto
 variable [though is less help in some dynamically allocated item].

    const void *LO_LIMIT=0x1000
    void       *HI_LIMIT=0;  //assign value

    int verify(void **PtrLoc){ void *Ptr=(*PtrLoc), *Rtn=NULL;
       asm(
          'mov (%ebp+4),%eax\r',  'mov %eax,(Rtn)\r'  //syntax?????
          :  :  %eax :                                //?????
       );
       if( LO_LIMIT <= (unsigned)Ptr   &&  (unsigned)Ptr < HI_LIMIT){
          ;
          return 1;
       };
       printf("Instr@%x used Pointer @%x contains %x",Rtn,PtrLoc,Loc);
       printf(" outside range %x to %x\n", LO_LIMIT, HI_LIMIT);
       ;  return 0;
   };

 Assuming of course that RhinoHIDE can turn a numerical code address
 back to a function name, and data address back to a variable name.

  
-- 
   ^-^-^-@@-^-;-^   http://www.xemu.demon.co.uk/
        (..)__u     news:alt.smoking.mooses

- Raw text -


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