ROTATE-BYTE on very large positions exhausts memory unnecessarily

Bug #2042937 reported by Paul F. Dietz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

Rotating bits far out in an integer, well past the last bit actually stored in its representation, leaves the integer unchanged. However, SB-ROTATE-BYTE:ROTATE-BYTE runs out of memory. It appears to expand the integer, perform the rotation, then normalize. Don't do that.

(sb-rotate-byte:rotate-byte 1 (byte 2 100000000000) 17) ==> memory exhausted

(sb-rotate-byte:rotate-byte 2 (byte 13 100000000000) (1- most-negative-fixnum)) ==> memory exhausted

Revision history for this message
Stas Boukarev (stassats) wrote :

rotate-byte shouldn't really be used with anything other than (byte 32/64 0) in any serious code.

Changed in sbcl:
status: New → Won't Fix
Revision history for this message
Christophe Rhodes (csr21-cantab) wrote :

Agreed in general with Stas' comment, though mitigating this issue is straightforward I think.

There's a similar problem with e.g.

  (dpb -1 (byte 2 1000000000000) -1)

Changed in sbcl:
status: Won't Fix → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.