chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #1005: pointer data structures don't overflow reliabl


From: Chicken Trac
Subject: [Chicken-janitors] #1005: pointer data structures don't overflow reliably, also this does not catch mmap error situations
Date: Thu, 11 Apr 2013 13:12:18 -0000

#1005: pointer data structures don't overflow reliably, also this does not catch
mmap error situations
--------------------------------------+-------------------------------------
 Reporter:  ckeen                     |       Owner:         
     Type:  defect                    |      Status:  new    
 Priority:  major                     |   Milestone:  someday
Component:  unknown                   |     Version:  4.8.x  
 Keywords:  mmap ffi pointer suckage  |  
--------------------------------------+-------------------------------------
 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.

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/1005>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]