I think I found an SBCL bug, would somebody run this for me?
Posted: Thu Dec 30, 2010 2:05 pm
This code uses C to malloc 32 bytes of memory. Then I use system-area-ub32-copy and system-area-ub32-fill. The behavior of FILL is incorrect I think (in these tests, I think it should give the same output as the copying).
My output is as follows on a 64 bit machine. This test case came from code that worked on a 32bit machine, but broke on the 64bit one. I think system-area-ubXX-fill is the culprit.
Code: Select all
(defvar *sap* (alien-funcall (extern-alien "malloc" (function system-area-pointer unsigned)) 32))
(defun zero-sap () (sb-kernel:system-area-ub32-fill 0 *sap* 0 8))
(defun print-sap ()
(format t "~%~8,'0x ~8,'0x ~8,'0x ~8,'0x ~8,'0x ~8,'0x ~8,'0x ~8,'0x"
(sb-sys:sap-ref-32 *sap* 0) (sb-sys:sap-ref-32 *sap* 4) (sb-sys:sap-ref-32 *sap* 8) (sb-sys:sap-ref-32 *sap* 12)
(sb-sys:sap-ref-32 *sap* 16) (sb-sys:sap-ref-32 *sap* 20) (sb-sys:sap-ref-32 *sap* 24)
(sb-sys:sap-ref-32 *sap* 28)))
(format t "~%UNSIGNED32 Copy...")
(let ((vector (make-array 8 :element-type '(unsigned-byte 32) :initial-element #xBADDBEEF)))
(sb-sys:with-pinned-objects (vector)
(sb-kernel:system-area-ub32-copy (sb-sys:vector-sap vector) 0 *sap* 0 8)
(print-sap)
(zero-sap)))
(format t "~%UNSIGNED32 Fill...")
(progn (sb-kernel:system-area-ub32-fill #xBADDBEEF *sap* 0 8)
(print-sap)
(zero-sap))
(format t "~%UNSIGNED8 Copy...")
(let ((vector (make-array 32 :element-type '(unsigned-byte 8) :initial-element #xAD)))
(sb-sys:with-pinned-objects (vector)
(sb-kernel:system-area-ub8-copy (sb-sys:vector-sap vector) 0 *sap* 0 32)
(print-sap)
(zero-sap)))
(format t "~%UNSIGNED8 Fill...")
(progn (sb-kernel:system-area-ub8-fill #xAD *sap* 0 32)
(print-sap)
(zero-sap))
Code: Select all
my output on SBCL 1.0.44.gentoo-r0 on a 64 bit machine
UNSIGNED32 Copy...
BADDBEEF BADDBEEF BADDBEEF BADDBEEF BADDBEEF BADDBEEF BADDBEEF BADDBEEF
UNSIGNED32 Fill...
BADDBEEF 00000000 BADDBEEF 00000000 BADDBEEF 00000000 BADDBEEF 00000000
UNSIGNED8 Copy...
ADADADAD ADADADAD ADADADAD ADADADAD ADADADAD ADADADAD ADADADAD ADADADAD
UNSIGNED8 Fill...
000000AD 00000000 000000AD 00000000 000000AD 00000000 000000AD 00000000