delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/14/00:00:26

Sender: nate AT cartsys DOT com
Message-ID: <36C657F1.50F398A8@cartsys.com>
Date: Sat, 13 Feb 1999 20:58:25 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Exception handling
Reply-To: djgpp AT delorie DOT com

I am writing a malloc debugger that uses page protection to catch
illegal accesses.  (Like ElectricFence, but with some more features.) 
There is a variety of stuff I want the page fault handler to do.  It
needs access to the registers at the time of the crash, as well as the
error code and cr2.  Additionally, I want to be able to restart the
faulting instruction, after manipulating the page tables to legalize the
access (to implement write-only pages).  Under Linux, I can do this with
a simple signal handler; a second arg is available to get the registers,
and a `return' will restart.

But under DJGPP, this looks more difficult.  I don't think a signal
handler can get the crashing registers.  And if it returns the library
code explicitly aborts.  (Is this done for a reason, or just because
most signal handlers that return haven't actually fixed the problem?) 
Do I need to write a DPMI  exception handler of my own?

And incidentally, is there a better way to allocate page-multiple
page-aligned blocks than rounding `malloc's up?
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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