delorie.com/djgpp/bugs/show.cgi   search  
Bug 000014

When Created: 07/19/1995 11:27:47
Against DJGPP version: 2.00.beta1
By whom: sandmann@clio.rice.edu
Abstract: Problems with exception design
Since the exception structure is static, a second exception which
happens before a first is finished causes lots of problems (potential
hangs, etc).  The protections to prevent this in the code are 
currently inadequate.  For example, a CTRL-C in the middle of 
a FPU emulation.

Note added: 07/20/1995 21:25:10
By whom: terra@diku.dk
Making the exception structure an array instead of a single element
doesn't look too complicated, nor does it take up a lot of memory.
If anyone thinks it does, then save fewer registers.  Esp, Ebp, and Eip
seem to be enough.

Using malloc in an exception handler is probably out of the question,
so a static array is the best we can do.  (Hmm... could be allocate
storage on some stack?)

Solution added: 07/24/1995 00:46:59
By whom: sandmann@clio.rice.edu
I have made exception handlers set the state of the interrupt flag to
disable interrupts when executing.  This would not fix the problem 
with true nested exceptions, but I expect this to be very rare.  It
should solve the problem of ctrl-c and timers in the middle of 
exception handlers.
Eventually I think we need to copy the current working version to 
the stack, but the exception stack itself is also static (sigh).
Lets see if anyone sees problems with the new setup; it may not
enable interrupts if IOPL != CPL, or it may not disable them at all.

Note added: 11/15/1995 23:26:26
By whom: sandmann@clio.rice.edu
The bugfix described above does indeed cause problems on some systems.
In particular, on a FPU-less box it was reported that the clock ticks
stop coming when floating emulation is used.  Reversing the patch 
solved the problem for that user.
One fix would be to fix longjmp to look at the IF flag to be restored
and do the appropriate NOP, CLI, STI as necessary to do the restore,
since popf or iret will not do the restore at certain IOPLs.
The correct fix is to make exceptions reentrant, but I don't have 
time to mess with that now.

Solution added: 12/19/1995 23:39:39
By whom: sandmann@clio.rice.edu
The exception handling was recoded so that the exception structure
is on the stack, and contains a pointer to the previous exception.
There is a global variable which points to the current exception
structure (NULL if none).  setjmp() saves the current exception
state pointer; longjmp() restores it.  The various problems associated
with the single static design should be fixed.

Fixed in version 2.00.beta5 on 01/25/1996 07:42:47
By whom: dj@delorie.com



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