Mail Archives: djgpp/1999/02/14/00:00:26
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 -