Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#794 closed defect (invalid)

on 32bit systems srfi-4 make- procedures fail where make-vector succeeds

Reported by: Christian Kellermann Owned by: Christian Kellermann
Priority: major Milestone: 4.9.0
Component: core libraries Version: 4.7.x
Keywords: srfi-4 make-vector 32bit Cc:
Estimated difficulty:

Description

$ csi -n

CHICKEN
(c)2008-2011 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.7.5 (rev b7f7e36)
openbsd-unix-gnu-x86 [ manyargs dload ptables ]
compiled 2012-03-02 on necronomicon.my.domain (OpenBSD)

#;1> (use srfi-4)
; loading /home/ckeen/chickens/master/lib/chicken/6/srfi-4.import.so ...
; loading library srfi-4 ...
#;2> (make-vector 12000000 0)
#(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
#;3> (make-u32vector 12000000 0)

Error: out of range
48000000
16777215

        Call history:

        <syntax>          (make-u32vector 12000000 0)
        <eval>    (make-u32vector 12000000 0)   <--

On 64 bit this works as expected. Affected is current master, 4.7.0 and the stability branch.

Change History (6)

comment:1 Changed 10 years ago by Christian Kellermann

16777215 is the biggest number that works, does that ring a bell?

comment:2 in reply to:  1 Changed 10 years ago by Christian Kellermann

Replying to ckeen:

16777215 is the biggest number that works, does that ring a bell?

forget this it is late...

comment:3 Changed 10 years ago by Jim Ursetto

Status: newassigned

Byte vector objects (strings, blobs) are limited to 24-bit length (0 - 16777215 bytes).

srfi-4 vectors are implemented with a srfi-4 header on top of a blob. Therefore u32 vectors are limited to 4,194,303 entries (since 4194303 words * 4 bytes/word = 16777212 bytes), in other words a 22-bit length.

So this can be chalked up to a confusing error message and a lack of documentation on the limits on srfi-4 vector length.

Naturally this occurs on 64-bit platforms as well, but the length is 54 bits instead of 56 bits, so you are unlikely to hit either limit; nor would I advise you to try.

comment:4 Changed 10 years ago by Christian Kellermann

A patch checking the length limits and producing better error messages as well as documenting these limits in the manual has been pushed to chicken-hackers for review.

comment:5 Changed 10 years ago by Christian Kellermann

Resolution: invalid
Status: assignedclosed

Basically the error message is correct, the reasons could be explained better as Jim pointed out.

comment:6 Changed 9 years ago by felix winkelmann

Milestone: 4.8.04.9.0

Milestone 4.8.0 deleted

Note: See TracTickets for help on using tickets.