From: Michael S. <msl...@co...> - 2004-01-21 12:20:48
|
Gwenole, > Actually, the sigsegv handler code is the same as for B2. I have just > hacked around to use Mach exceptions to handle screen faults (early so > that we don't need the whole context) + other faults like writes to > ROM. However, SheepShaver hangs early after a few seconds. I think > this is because we have not taught our Mach exception handler to > execute with an alternate stack (set by sigaltstack() or another means > we can define) as we should. Is that possible to do? The short answer is no it is not possible in any way I know. I really would not be using sigaltstack() if I were you. It dates from old BSDs. The reason it ever existed is that some signal handlers in other systems got not only the signal number but two other args, one of which was a pointer into a structure that contained cpu context. In these old versions of BSD you had no easy way of finding where your context was on the stack, later versions had header files that helped. There are also times when you really do need an alternate stack for your signals from your normal stack, so it is good to use there. But in any case I would not use sigaltstack() for multi-threaded programs. Also as you may be seeing, the interaction between exceptions and the alternate signal stack is probably not something that Apple ever debugged. Now the long answer to why you cannot put the exception handler on the alternate signal stack. What happen in Mach exceptions is that you have some thread somewhere that handles the exceptions. It can be in another process or the same process. You create a Mach message port and set it up so that one thread will communicate to the exception thread through that port. So what you have in the B2 case is that I have created one thread that sits in a loop and all it does is wake-up whenever it hears about an exception and handles it. When it is awake the other thread that caused the exception is suspended. It is only that one thread that you setup to communicate with the exception handler that will communicate through the Mach port, which is what you want but different from how the signal code on a typical Unix works. I should have some time tomorrow to look at the SS code, so I will take a look and see what I can do. mzs |