Summary

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

Metadata

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.

Changes and comments

[2012-03-02 23:14:02 UTC] ckeen wrote:

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

[2012-03-02 23:15:39 UTC] ckeen wrote:

Replying to ckeen: > 16777215 is the biggest number that works, does that ring a bell?

forget this it is late...

[2012-03-02 23:43:12 UTC] zbigniew changed status from new to assigned

[2012-03-02 23:43:12 UTC] zbigniew wrote:

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.

[2012-03-11 20:49:20 UTC] ckeen wrote:

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.

[2012-03-18 17:08:49 UTC] ckeen changed status from assigned to closed

[2012-03-18 17:08:49 UTC] ckeen set resolution to invalid

[2012-03-18 17:08:49 UTC] ckeen wrote:

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

[2012-09-24 21:47:48 UTC] felix changed milestone from 4.8.0 to 4.9.0

[2012-09-24 21:47:48 UTC] felix wrote:

Milestone 4.8.0 deleted