Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Sep 1998 10:52:44 +0200 (SAT)
From:      Graham Wheeler <gram@cdsec.com>
To:        bright@hotjobs.com (Alfred Perlstein)
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Catching SIGSEGV
Message-ID:  <199809160852.KAA02623@cdsec.com>
In-Reply-To: <Pine.BSF.3.96.980915123624.21829G-100000@bright.fx.genx.net> from "Alfred Perlstein" at Sep 15, 98 12:43:05 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> "there is no buffer in memory" it's the reading of the memory that's
> causing the fault, someone in this thread brought up setjmp, that could
> also work, another trick would be to change the value of 'ptr' to
> something valid, (in the handler) then when the instruction is restarted
> it will access valid memory and proceed as planned.

The handler was already doing that (setting ptr to something valid).
The original question was why does it still SEGV after ptr is set to
a valid value?

> > On Tue, 15 Sep 1998, Mikael Karpberg wrote:
> > > My guess is that you would want to declare things like this:
> > > volatile int nsegv = 0;
> > > volatile int *ptr;
> > > int zero = 0;
> > > 
> > > Then the restarted "buf = *ptr;" line will not use a buffered value for ptr
> > > but read it from memory. I think.
> 
> that is TOTALLY wrong. no matter what happens the CPU will fault on the
> fetch from the bad address.

It isn't *totally* wrong, because the handler was setting ptr to a valid
value. However, in practice it is insufficient bacuse the instruction 
that gets restarted is at the m/c level rather than the level of C 
statements, so the pointer will already be in a register, even though
it is (or should be) volatile. So the only solution is to use setjmp/longjmp.

-- 
Dr Graham Wheeler                          E-mail: gram@cdsec.com
Citadel Data Security                      Phone:  +27(21)23-6065/6/7
Internet/Intranet Network Specialists      Mobile: +27(83)253-9864
Firewalls/Virtual Private Networks         Fax:    +27(21)24-3656
Data Security Products                     WWW:    http://www.cdsec.com/




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809160852.KAA02623>