From owner-freebsd-hackers Wed Sep 16 01:47:24 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA03959 for freebsd-hackers-outgoing; Wed, 16 Sep 1998 01:47:24 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from citadel.cdsec.com (citadel.cdsec.com [192.96.22.18]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA03917 for ; Wed, 16 Sep 1998 01:47:05 -0700 (PDT) (envelope-from gram@cdsec.com) Received: (from nobody@localhost) by citadel.cdsec.com (8.8.5/8.6.9) id KAA25941; Wed, 16 Sep 1998 10:54:06 +0200 (SAT) Received: by citadel via recvmail id 25939; Wed Sep 16 10:53:59 1998 From: Graham Wheeler Message-Id: <199809160852.KAA02623@cdsec.com> Subject: Re: Catching SIGSEGV To: bright@hotjobs.com (Alfred Perlstein) Date: Wed, 16 Sep 1998 10:52:44 +0200 (SAT) Cc: hackers@FreeBSD.ORG In-Reply-To: from "Alfred Perlstein" at Sep 15, 98 12:43:05 pm X-Mailer: ELM [version 2.4 PL25-h4.1] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > "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