[Sbcl-devel] compiler error with dynamic-extent vectors: sbcl fails on ironclad's update-digest-from-stream

7 views
Skip to first unread message

Andreas Franke

unread,
Oct 1, 2023, 10:34:31 PM10/1/23
to sbcl-...@lists.sourceforge.net
Current SBCL does not seem to like some dynamic-extent vectors as used in this function:
https://github.com/sharplispers/ironclad/blob/master/src/digests/digest.lisp#L16


$ ./run-sbcl.sh --no-userinit --no-sysinit --eval "(defpackage :crypto (:use :cl))" --eval '(compile-file "/tmp/ironclad-digest.lisp")'
This is SBCL 2.3.9.29-053910a97-WIP [...]
; compiling file "/tmp/ironclad-digest.lisp" (written 02 OCT 2023 04:01:20 AM):

debugger invoked on a TYPE-ERROR @52C48512 in thread
#<THREAD tid=342194 "main thread" RUNNING {10010B0003}>:
The value
131088
is not of type
(OR SB-C:TN NULL)



A reduced reproducer is:
$ ./run-sbcl.sh --no-sysinit --no-userinit --eval "(compile (lambda () (let ((buffer (make-array (* 128 1024) :element-type '(unsigned-byte 8)))) (declare (dynamic-extent buffer)) (f2 buffer))))"



When :element-type '(unsigned-byte 8) is removed, the numeric value in the error message changes:

$ ./run-sbcl.sh --no-sysinit --no-userinit --eval "(compile (lambda () (let ((buffer (make-array (* 128 1024)))) (declare (dynamic-extent buffer)) (f2 buffer))))"
[...]
debugger invoked on a TYPE-ERROR @52C48512 in thread
#<THREAD tid=343265 "main thread" RUNNING {10010B0003}>:
The value
1048592
is not of type
(OR SB-C:TN NULL)




_______________________________________________
Sbcl-devel mailing list
Sbcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-devel

Charles Zhang via Sbcl-devel

unread,
Oct 2, 2023, 6:29:21 PM10/2/23
to sbcl-...@lists.sourceforge.net, Andreas Franke
Fixed. Thanks for the report.





Andreas Franke

unread,
Oct 7, 2023, 12:52:08 PM10/7/23
to sbcl-...@lists.sourceforge.net
Thanks for the ironclad fix!
 
$ ./run-sbcl.sh --script <<EOF

(defun foo ()
  (let* ((x nil)
         (y (make-array 1)))
    (declare (dynamic-extent x y))
    (loop repeat 1 do (push 0 x))
    (setf (aref y 0) 'whatever)))
(compile 'foo)
EOF
Unhandled TYPE-ERROR in thread #<SB-THREAD:THREAD tid=52477 "main thread" RUNNING
                                  {10010B8003}>:
  The value
    NIL
  is not of type
    SB-C:TN
  when binding SB-C:TN
Backtrace for: #<SB-THREAD:THREAD tid=52477 "main thread" RUNNING {10010B8003}>
0: (SB-C:REFERENCE-TN NIL NIL) [external]
1: (SB-C::%POP-VALUES-IR2-CONVERT-OPTIMIZER #<SB-C::COMBINATION :FUN #<SB-C::REF  :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME SB-C::%POP-VALUES :TYPE #1=#<SB-KERNEL:FUN-TYPE (FUNCTION (T) (VALUES T &OPTIONAL))> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :GLOBAL-FUNCTION {1001126A53}> {1001126B53}> :ARGS (#<SB-C::REF  :LEAF #<SB-KERNEL:CONSTANT :VALUE #<SB-C::LVAR 1 {1001126253}> {1001126CD3}> {1001126D33}>) {1001126BB3}> #<SB-C::IR2-BLOCK  {1001127033}>)
2: (SB-C::IR2-CONVERT-BLOCK #<SB-C::CBLOCK 4 :START c2 {1001126983}>)
3: (SB-C:IR2-CONVERT #<SB-C:COMPONENT :NAME "<unknown>" {10010E5F03}>)
4: (SB-C::%COMPILE-COMPONENT #<SB-C:COMPONENT :NAME "<unknown>" {10010E5F03}>)
5: (SB-C::COMPILE-COMPONENT #<SB-C:COMPONENT :NAME "<unknown>" {10010E5F03}>)
6: (SB-C::%COMPILE (SB-INT:NAMED-LAMBDA FOO NIL (BLOCK FOO (LET* ((X NIL) (Y #)) (DECLARE (DYNAMIC-EXTENT X Y)) (LOOP REPEAT 1 DO (PUSH 0 X)) (SETF (AREF Y 0) (QUOTE WHATEVER))))) NIL NIL)
 

Charles Zhang via Sbcl-devel

unread,
Oct 7, 2023, 1:08:47 PM10/7/23
to sbcl-...@lists.sourceforge.net, Andreas Franke
I'm looking into this one now. Thanks for the report.





Reply all
Reply to author
Forward
0 new messages