bug in mmap() and mremap() return value - and a fix
Luís Oliveira
loliveira at common-lisp.net
Mon Jan 6 22:25:37 UTC 2014
On Mon, Jan 6, 2014 at 9:06 PM, Massimiliano Ghilardi
<massimiliano.ghilardi at gmail.com> wrote:
> In such cases, it means the underlying C mmap() function returned
> successfully a pointer in the top half of the addressable virtual
> memory, but the Lisp wrapper for mmap() and mremap() chokes on such
> pointers.
>
> A patch that solves this problem is attached.
>
> Feedback on the analysis and the solution is welcome :)
First off, there's another bug: we should be using :intptr rather than
:long for the return type. To be fair, CFFI probably didn't have that
type yet when that code was written.
The return-filter can then cast the return value to a pointer using
something like:
(with-foreign-object (p :intptr)
(setf (mem-ref p :intptr) <the-return-value>)
(mem-ref p :pointer))
Alternatively, we could store a -1 cast to pointer and compare the
return value against that. (Hmm, maybe CFFI should have a cast
operation. :-))
I'm not sure any of these alternatives are better than your solution.
What do you think?
--
Luís Oliveira
http://kerno.org/~luis/
More information about the osicat-devel
mailing list