phantomics / april

The APL programming language (a subset thereof) compiling to Common Lisp.
Apache License 2.0
602 stars 31 forks source link

Bug in x86_64 assembly generation of ⍉ on SBCL #283

Closed paulapatience closed 3 months ago

paulapatience commented 6 months ago

On SBCL 2.4.0, running:

(april:april "m←1 2⍴1 2◊⍉m")

results in the following error:

failed AVER: (MEMBER SB-X86-64-ASM::SIZE '(:DWORD :QWORD))
This is probably a bug in SBCL itself. (Alternatively, SBCL
might have been corrupted by bad user code, e.g. by an undefined
Lisp operation like (FMAKUNBOUND 'COMPILE), or by stray pointers
from alien code or from unsafe Lisp code; or there might be a
bug in the OS or hardware that SBCL is running on.) If it seems
to be a bug in SBCL itself, the maintainers would like to know
about it. Bug reports are welcome on the SBCL mailing lists,
which you can find at <http://sbcl.sourceforge.net/>.
   [Condition of type SB-INT:BUG]

Restarts:
 0: [RETRY] Retry SLY interactive evaluation request.
 1: [*ABORT] Return to SLY's top level.
 2: [ABORT] abort thread (#<THREAD tid=4662 "slynk-worker" RUNNING {1008E4CB43}>)

Backtrace:
 0: ("BSWAP" #<SB-ASSEM:SEGMENT {1008F5AF23}> 5 #S(SB-X86-64-ASM::REG :ID 80))
 1: (SB-ASSEM::%ASSEMBLE #<SB-ASSEM:SEGMENT {1008F5AF23}> (#<SB-ASSEM::STMT IGNORE {1008F1ED63}> . #<SB-ASSEM::STMT .ALIGN {1008F5B063}>))
 2: (SB-ASSEM:ASSEMBLE-SECTIONS #S(SB-ASSEM::ASMSTREAM :DATA-SECTION (#<SB-ASSEM::STMT IGNORE {1008F1ED63}> . #<SB-ASSEM::STMT .ALIGN {1008F5B063}>) :CODE-SECTION (#1=#<SB-ASSEM::STMT IGNORE {1008F1EDA3}>..
 3: (SB-C::GENERATE-CODE #<SB-C:COMPONENT :NAME "<unknown>" {1008EFD803}>)
 4: (SB-C::%COMPILE-COMPONENT #<SB-C:COMPONENT :NAME "<unknown>" {1008EFD803}>)
 5: (SB-C::COMPILE-COMPONENT #<SB-C:COMPONENT :NAME "<unknown>" {1008EFD803}>)
 6: (SB-C::%COMPILE (LAMBDA #1=(VARRAY::A VARRAY::B VARRAY::C VARRAY::D) (DECLARE (OPTIMIZE # #)) (VARRAY::VOP-PH . #1#)) NIL NIL)
 7: ((LAMBDA NIL :IN SB-C:COMPILE-IN-LEXENV))
 8: ((FLET SB-C::WITH-IT :IN SB-C::%WITH-COMPILATION-UNIT))
 9: (SB-C:COMPILE-IN-LEXENV (LAMBDA #1=(VARRAY::A VARRAY::B VARRAY::C VARRAY::D) (DECLARE (OPTIMIZE # #)) (VARRAY::VOP-PH . #1#)) #<NULL-LEXENV> NIL NIL NIL NIL NIL)
10: (COMPILE NIL (LAMBDA #1=(VARRAY::A VARRAY::B VARRAY::C VARRAY::D) (DECLARE (OPTIMIZE # #)) (VARRAY::VOP-PH . #1#)))
11: (SB-EVAL::EVAL-NEXT-LET*-BINDING ((#:NEW1 COMPILE NIL (QUOTE #))) NIL #<SB-EVAL::ENV {1008EF9ED3}> #<FUNCTION (LAMBDA (SB-EVAL::ENV) :IN SB-EVAL::EVAL-LET*) {1008EF9F2B}>)
12: (SB-EVAL:EVAL-IN-NATIVE-ENVIRONMENT (PROGN (SB-C:DEFKNOWN VARRAY::VOP-PH (#1=# #1# #1# #1#) #1# (SB-C:FOLDABLE SB-C:FLUSHABLE SB-C:MOVABLE) :OVERWRITE-FNDB-SILENTLY ...) (UNLESS (FBOUNDP #) (PROCLAIM ..
13: (EVAL (PROGN (SB-C:DEFKNOWN VARRAY::VOP-PH (#1=# #1# #1# #1#) #1# (SB-C:FOLDABLE SB-C:FLUSHABLE SB-C:MOVABLE) :OVERWRITE-FNDB-SILENTLY ...) (UNLESS (FBOUNDP #) (PROCLAIM #) (SETF #2=# #)) (SB-C:DEFINE..
14: ((LAMBDA (VARRAY:VARRAY VARRAY::SBESIZE VARRAY::GET-SPAN VARRAY::OUTPUT) :IN "/home/paul/external/april/varray/base.lisp") #<VARRAY:VADER-PERMUTE {1008E8C3B3}> 1 #<unused argument> #2A((0) (0)))
15: ((:METHOD VARRAY::RENDER (VARRAY:VARRAY)) #<VARRAY:VADER-PERMUTE {1008E8C3B3}>) [fast-method]
16: ((LAMBDA ()))
17: (SB-INT:SIMPLE-EVAL-IN-LEXENV (APRIL:APRIL "m←1 2⍴1 2◊⍉m") #<NULL-LEXENV>)
18: (EVAL (APRIL:APRIL "m←1 2⍴1 2◊⍉m"))
...
phantomics commented 3 months ago

This is fixed, some cases weren't properly handled by the assembler.