Mail Archives: djgpp/1997/11/08/15:34:35
At 10:07 11/7/1997 +0300, Roman Suzi wrote:
>Eli Zaretskii wrote:
>
>>On Mon, 3 Nov 1997, Roman Suzi wrote:
>>
>>> My posting about Fighting Gen.Prot.Faults
>>> was addressing the question is there any mechanism
>>> in DJGPP to intercept GPEs, caused by stack overflow ?
>>>
>>> It seems, there is not any...
>>
>>Did you try to install a handler for the signal SIGSEGV, using the
>>`signal' library function? If so, what did you see?
>
> Yes, of course.
>
>>> Possibly, existing DPMIs are not permitting to
>>> intercept GPF of stack frame.
>>
>>What DPMI server did you use?
>
> CWSDPMI
This example worked for me under both CWSDPMI r3 and Windows 3.1.
#include <stdio.h>
#include <signal.h>
void handler(int sig)
{
printf("Received signal %d\n",sig);
fflush(stdout);
/* clean up */
exit(1); /* or whatever else */
}
int main(void)
{
signal(SIGSEGV,handler);
/* Overflow the stack */
alloca(1000000);
/* Touch the stack to cause a fault */
printf("This isn't going to work");
return 0;
}
Running it prints "Received signal 291", which is evidently SIGSEGV.
So I'm not sure why it doesn't work for you, unless you're doing something
different. Hmm.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -