Date: Tue, 22 Jun 1999 11:04:03 +0200 From: Ladavac Marino <mladavac@metropolitan.at> To: 'Scott Gasch' <scott@mail.medsp.com>, freebsd-questions@freebsd.org Subject: RE: IsBadReadPointer Message-ID: <55586E7391ACD211B9730000C110027617968D@r-lmh-wi-100.corpnet.at>
next in thread | raw e-mail | index | archive | help
> -----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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55586E7391ACD211B9730000C110027617968D>