Opened 12 years ago
Last modified 8 years ago
#1005 reopened defect
pointer data structures don't overflow reliably, also this does not catch mmap error situations — at Initial Version
Reported by: | Christian Kellermann | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | someday |
Component: | extensions | Version: | |
Keywords: | mmap ffi pointer suckage | Cc: | |
Estimated difficulty: | medium |
Description
I have just came across this issue when dealing with a failed mmap FFI call. In this case mmap (The C function) will return a MAP_FAILED which is defined as (void*)-1 on linux and OpenBSD.
The mmap code checks for this by doing a (eq? -1 addr2). This is fine for 32 bit systems but not for 64 bit systems.
;; on 32 bit #;2> (address->pointer -1) #<pointer 0xffffffff> ;; on 64 bit #;2> (address->pointer -1) #<pointer 0x0> #;3> (pointer->address #2) 1.84467440737096e+19
Note how the pointer printing code also gets it wrong.
A current workaround would be to explicitly check for the -1 pointer representation:
(pointer=? (address->pointer -1) addr2)
This works but looks icky. I am not sure how to handle this right.
Note: See
TracTickets for help on using
tickets.