www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/08/15:34:35

Date: Sat, 8 Nov 1997 12:33:01 -0800 (PST)
Message-Id: <199711082033.MAA01400@adit.ap.net>
Mime-Version: 1.0
To: nuser AT rsuzi DOT pgu DOT karelia DOT ru, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: General Protection Fault interception vs. Checking stack

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 -


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