From owner-freebsd-questions Tue Jun 22 2: 7:19 1999 Delivered-To: freebsd-questions@freebsd.org Received: from titan.metropolitan.at (mail.metropolitan.at [195.212.98.131]) by hub.freebsd.org (Postfix) with ESMTP id B3E8514BEC for ; Tue, 22 Jun 1999 02:07:07 -0700 (PDT) (envelope-from mladavac@metropolitan.at) Received: by TITAN with Internet Mail Service (5.0.1458.49) id ; Tue, 22 Jun 1999 11:10:02 +0200 Message-ID: <55586E7391ACD211B9730000C110027617968D@r-lmh-wi-100.corpnet.at> From: Ladavac Marino To: 'Scott Gasch' , freebsd-questions@freebsd.org Subject: RE: IsBadReadPointer Date: Tue, 22 Jun 1999 11:04:03 +0200 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1458.49) Content-Type: text/plain Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > -----Original Message----- > From: Scott Gasch [SMTP:scott@mail.medsp.com] > Sent: Tuesday, June 22, 1999 10:28 AM > To: freebsd-questions@freebsd.org > Subject: IsBadReadPointer > > > Hi there, > > In Win32 there are several system calls that can be used to check > whether pointers are vaild or not. They are called IsBadReadPointer, > IsBadWritePointer, IsBadStringPointer, etc... > > I guess they work by checking the permission of the page of memory the > pointers point to. I find them useful debugging tools and often write > preconditions based on them as it is often better to check a pointer > for readibility than simply checking for NULL. > > My question is: does the same thing exist in FreeBSD? [ML] A similar, but slightly more efficient thing, can be built around sigaction(2), signal handlers for SIGSEGV and SIGBUS, and setjmp(3)/longjmp(3). In other words, you proceed as if the pointers were valid, and let the OS trap the invalid ones--you bail out with longjmp. Slightly more efficient because if the pointer is OK, nothing happens; you only take a syscall/trap if the pointer points to an unmapped/mapped-with-insufficient-protection page. IsBad* family always has to make a syscall to check the address mappings. [ML] /Marino > Thanks for your help, > Scott > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message