(ikarus system $foreign) pointers bugs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ikarus Scheme |
Fix Committed
|
Medium
|
Abdulaziz Ghuloum |
Bug Description
Ikarus Scheme version 0.0.3+ (revision 1597, build 2008-09-13)
Copyright (c) 2006-2008 Abdulaziz Ghuloum
> (import (ikarus system $foreign))
> (define p (malloc 4))
> (pointer-set-long p 0 #xffffffff)
> (pointer-ref-ulong p 0)
-1 ;; should be #xffffffff
> (pointer-ref-long p 0)
-1
> (pointer-set-int p 0 #xffffffff)
> (pointer-ref-uint p 0)
-1 ;; should be #xffffffff
> (pointer-ref-int p 0)
-1
> (pointer-set-short p 0 #xffff)
> (pointer-ref-ushort p 0)
65535
> (pointer-ref-short p 0)
-1
> (pointer-set-char p 0 #xff)
> (pointer-ref-uchar p 0)
255
> (pointer-ref-char p 0)
-1
>
Offsets are wrong because (((long)ref(p, off_pointer_data)) + unfix(off)) is doing integer addition:
> (pointer-set-char p 0 #x12)
> (pointer-set-char p 1 #x34)
> (pointer-set-char p 2 #x56)
> (pointer-set-char p 3 #x78)
> (pointer-ref-ushort p 1)
22068 ;; should be 30806 (#x7856)
> (number->string 22068 16)
"5634"
>
Related branches
Changed in ikarus: | |
milestone: | none → 0.0.4 |
On Sep 13, 2008, at 3:57 PM, Derick Eddington wrote:
> Offsets are wrong because (((long)ref(p, off_pointer_data)) + unfix
> (off)) is doing integer addition:
The offsets are intended to be in bytes, not in multiples int/long. The pointer is not
of the sizeof the char/short/
assumed to be homogeneous. It might be a struct containing
bytes, shorts, longs, etc.
I'll investigate the other issue later.
Thanks.