Re: Function to verify a virtual address?
From: Måns Rullgård (mru_at_inprovide.com)
Date: 03/23/05
- Next message: John Reiser: "Re: Function to verify a virtual address?"
- Previous message: Timur Tabi: "Function to verify a virtual address?"
- In reply to: Timur Tabi: "Function to verify a virtual address?"
- Next in thread: John Reiser: "Re: Function to verify a virtual address?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 23 Mar 2005 19:37:41 +0100
"Timur Tabi" <nospam_timur@tabi.org> writes:
> Is there a function that can verify a particular virtual address (or
> preferably, a range of virtual addresses) is valid for the current
> process? By valid, I mean that the process can read from that address
> without causing a segfault.
There is such explicit function. Instead, you can use a system call
like access(), and check for EFAULT. Quite often, mincore() is
mentioned in response to this question. mincore() does not do what
you want. It tells whether a page is resident in RAM, as opposed to
being swapped to disk. The man page doesn't say what it does with
unmapped pages.
That said, if you ever end up with pointers you don't know for sure
are valid, you have a design problem. There are many ways for a
pointer to be invalid in non-detectable ways, and it is use of these
pointers that causes serious trouble.
-- Måns Rullgård mru@inprovide.com
- Next message: John Reiser: "Re: Function to verify a virtual address?"
- Previous message: Timur Tabi: "Function to verify a virtual address?"
- In reply to: Timur Tabi: "Function to verify a virtual address?"
- Next in thread: John Reiser: "Re: Function to verify a virtual address?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|