Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory corruption issues on SBCL 1.5.6 #401

Closed
appleby opened this issue Aug 31, 2019 · 11 comments
Closed

Memory corruption issues on SBCL 1.5.6 #401

appleby opened this issue Aug 31, 2019 · 11 comments

Comments

@appleby
Copy link
Contributor

appleby commented Aug 31, 2019

quilc fails to compile with SBCL 1.5.6.

This is essentially the same issue as quil-lang/qvm#168

See also #397

$make clean quilc
rm -f quilc system-index.txt build-output.log
rm -f coverage-report/*.html
rm -f src/contrib/**/*.so src/contrib/**/*.dylib
sbcl --noinform --no-userinit --no-sysinit --non-interactive --load /Users/mappleby/quicklisp/setup.lisp --eval '(push (truename ".") asdf:*central-registry*)' --eval '(push :drakma-no-ssl *features*)' --eval "(push (truename \"../\") ql:*local-project-directories*)" \
                 \
                --eval '(ql:quickload "quilc")' \
                --eval '(ql:write-asdf-manifest-file "system-index.txt")'
To load "quilc":
  Load 1 ASDF system:
    quilc
; Loading "quilc"
.......................
sbcl --noinform --no-userinit --no-sysinit --non-interactive  \
                --eval "(setf sb-ext:\*on-package-variance\* '(:warn (:swank :swank-backend :swank-repl) :error t))" \
                --eval '(push :drakma-no-ssl *features*)' \
                --load "build-app.lisp" \
                 \

WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/cl-ppcre-20190521-git/cl-ppcre.asd" contains definition for system "cl-ppcre-test". Please only define "cl-ppcre" and secondary systems with a name starting with "cl-ppcre/" (e.g. "cl-ppcre/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/parse-float-20171019-git/parse-float.asd" contains definition for system "parse-float-tests". Please only define "parse-float" and secondary systems with a name starting with "parse-float/" (e.g. "parse-float/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/cl-fad-20190813-git/cl-fad.asd" contains definition for system "cl-fad-test". Please only define "cl-fad" and secondary systems with a name starting with "cl-fad/" (e.g. "cl-fad/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/pzmq-20190710-git/pzmq.asd" contains definition for system "pzmq-compat". Please only define "pzmq" and secondary systems with a name starting with "pzmq/" (e.g. "pzmq/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/pzmq-20190710-git/pzmq.asd" contains definition for system "pzmq-test". Please only define "pzmq" and secondary systems with a name starting with "pzmq/" (e.g. "pzmq/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/pzmq-20190710-git/pzmq.asd" contains definition for system "pzmq-examples". Please only define "pzmq" and secondary systems with a name starting with "pzmq/" (e.g. "pzmq/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/flexi-streams-20190107-git/flexi-streams.asd" contains definition for system "flexi-streams-test". Please only define "flexi-streams" and secondary systems with a name starting with "flexi-streams/" (e.g. "flexi-streams/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/trivial-utf-8-20111001-darcs/trivial-utf-8.asd" contains definition for system "trivial-utf-8-tests". Please only define "trivial-utf-8" and secondary systems with a name starting with "trivial-utf-8/" (e.g. "trivial-utf-8/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/puri-20180228-git/puri.asd" contains definition for system "puri-tests". Please only define "puri" and secondary systems with a name starting with "puri/" (e.g. "puri/test") in that file.
WARNING: System definition file #P"/Users/mappleby/quicklisp/dists/quicklisp/software/cl-base64-20150923-git/cl-base64.asd" contains definition for system "cl-base64-tests". Please only define "cl-base64" and secondary systems with a name starting with "cl-base64/" (e.g. "cl-base64/test") in that file.
WARNING: redefining CL-QUIL::LEXICAL-CONTEXT in DEFGENERIC
WARNING: redefining TRIVIAL-BENCHMARK:RUNNING in DEFGENERIC
WARNING: redefining TRIVIAL-BENCHMARK:METRICS in DEFGENERIC
WARNING: redefining TRIVIAL-BENCHMARK:STARTING-VALUE in DEFGENERIC
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
In file included from /Users/mappleby/src/repos/rigetti/quilc/src/contrib/tweedledum/tweedledum.c:8:
In file included from /Users/mappleby/src/repos/rigetti/quilc/src/contrib/tweedledum/tweedledum/include/tweedledum/algorithms/synthesis/dbs.hpp:18:
/Users/mappleby/src/repos/rigetti/quilc/src/contrib/tweedledum/tweedledum/libs/kitty/kitty/esop.hpp:36:2: warning: "DEPRECATED: the functions in this file are marked as deprecated. Most
      recent implementation can be found in https://github.com/hriener/easy/ in the file src/esop/constructors.hpp" [-W#warnings]
#warning "DEPRECATED: the functions in this file are marked as deprecated.  Most recent implementation can be found in https://github.com/hriener/easy/ in the file src/esop/cons...
 ^
1 warning generated.
; compiling file "/Users/mappleby/src/repos/rigetti/quilc/src/contrib/tweedledum/tweedledum.lisp" (written 01 AUG 2019 05:10:31 PM):
; compiling (DEFPACKAGE #:CL-QUIL.TWEEDLEDUM ...)
; compiling (IN-PACKAGE #:CL-QUIL.TWEEDLEDUM)
; compiling (DEFINE-FOREIGN-LIBRARY (LIBTWEEDLEDUM :SEARCH-PATH ...) ...)
; compiling (DEFVAR *TWEEDLEDUM-LIBS-LOADED* ...)
; compiling (DEFCFUN (%SYNTHESIS-DBS "tweedledum_synthesis_dbs") ...)
; compiling (DEFUN SYNTHESIS-DBS ...)
; compiling (DEFUN COMPILE-PERM-GATE-WITH-TWEEDLEDUM ...)
; compiling (DEFUN LOAD-TWEEDLEDUM ...)
; compiling (DEFUN RUN-TWEEDLEDUM-TESTS ...)

; wrote /Users/mappleby/.cache/common-lisp/sbcl-1.5.6-macosx-x64/Users/mappleby/src/repos/rigetti/quilc/src/contrib/tweedledum/tweedledum-tmpGHU3ALSV.fasl
; compilation finished in 0:00:00.025
Zapping info...
CORRUPTION WARNING in SBCL pid 55063(tid 0x51905c0):
Memory fault at 0x0 (pc=0x100001a697, fp=0x19feaf8, sp=0x19feaf0) tid 0x51905c0
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
While evaluating the form starting at line 13, column 0
  of #P"/Users/mappleby/src/repos/rigetti/quilc/build-app.lisp":
Unhandled SB-SYS:MEMORY-FAULT-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                                 {10004F04C3}>:
CORRUPTION WARNING in SBCL pid 55063(tid 0x51905c0):
Memory fault at 0x0 (pc=0x100001f917, fp=0x19fda20, sp=0x19fda18) tid 0x51905c0
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
  #<error printing a SB-SYS:MEMORY-FAULT-ERROR: #<SB-SYS:MEMORY-FAULT-ERROR {1006829273}>>

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {10004F04C3}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<SB-SYS:MEMORY-FAULT-ERROR {10068245B3}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<SB-SYS:MEMORY-FAULT-ERROR {10068245B3}>)
2: (INVOKE-DEBUGGER #<SB-SYS:MEMORY-FAULT-ERROR {10068245B3}>)
3: (ERROR SB-SYS:MEMORY-FAULT-ERROR :ADDRESS 0)
4: (SB-SYS:MEMORY-FAULT-ERROR #<unused argument> #.(SB-SYS:INT-SAP #X00000000))
5: ("foreign function: call_into_lisp")
6: ("foreign function: funcall2")
7: ("foreign function: handle_memory_fault_emulation_trap")
8: ("foreign function: signal_emulation_wrapper")
unhandled condition in --disable-debugger mode, quitting
CORRUPTION WARNING in SBCL pid 55063(tid 0x51905c0):
Memory fault at 0x0 (pc=0x1000018027, fp=0x19fdfb0, sp=0x19fdfa8) tid 0x51905c0
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
make: *** [quilc] Error 1
@appleby
Copy link
Contributor Author

appleby commented Aug 31, 2019

Quick-fix / bandaid PR similar to quil-lang/qvm#172 coming soon

@appleby
Copy link
Contributor Author

appleby commented Aug 31, 2019

Looks like there might be additional issues for cl-quil / quilc with SBCL 1.5.6 beyond just zap-info.

Changing issue title to indicate broader scope.

CL-QUIL-TESTS (Suite)
CORRUPTION WARNING in SBCL pid 55369(tid 0x6b965c0):
Memory fault at 0x0 (pc=0x21b007a4, fp=0x4fd280, sp=0x4fd278) tid 0x6b965c0
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
  TEST-LOGICAL-MATRIX-SANITY
Unhandled SB-SYS:MEMORY-FAULT-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                                 {10004F04C3}>:
  Unhandled memory fault at #x0.

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {10004F04C3}>
0: (SB-VM::FUNCALLABLE-INSTANCE-TRAMP)
1: (PRINC 2622008 #<error printing a SYMBOL: #<TYPE-ERROR expected-type: SYMBOL datum: (error printing condition)>>)
2: (SB-KERNEL:%MAP-FOR-EFFECT-ARITY-1 #<CLOSURE (LABELS CL-QUIL::TRY-COMPILER :IN CL-QUIL::APPLY-TRANSLATION-COMPILERS) {1005FC628B}> #(CL-QUIL::SWAP-TO-NATIVE-SWAPS CL-QUIL::CNOT-TO-NATIVE-CNOTS CL-QUIL::CZ-TO-NATIVE-CZS CL-QUIL::CCNOT-TO-CNOT CL-QUIL::PHASE-TO-RZ CL-QUIL::UCR-COMPILER-TO-CZ CL-QUIL::STATE-PREP-1Q-COMPILER CL-QUIL::STATE-PREP-2Q-COMPILER CL-QUIL::STATE-PREP-TRAMPOLINING-COMPILER CL-QUIL::RECOGNIZE-UCR #<CLOSURE (LAMBDA (&REST A::MORE) :IN A:CURRY) {100541C63B}> CL-QUIL::QS-COMPILER))
3: (CL-QUIL::APPLY-TRANSLATION-COMPILERS #<CONTROLLED FORKED Y 2 1 0> #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects> NIL)
4: (CL-QUIL::DEQUEUE-GATE-APPLICATION #<CONTROLLED FORKED Y 2 1 0> NIL)
5: (CL-QUIL::DEQUEUE-LOGICAL-TO-PHYSICAL :DRY-RUN NIL)
6: (CL-QUIL::DO-GREEDY-TEMPORAL-ADDRESSING (#<CONTROLLED FORKED Y 2 1 0>) #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects> :INITIAL-REWIRING #S(CL-QUIL::REWIRING :L2P #(NIL NIL NIL) :P2L #(NIL NIL NIL)) :USE-FREE-SWAPS T)
7: ((LABELS CL-QUIL::PROCESS-BLOCK :IN COMPILER-HOOK) #<CL-QUIL::BASIC-BLOCK ENTRY-BLK-597 len:1 in:0 out:term {1005FC3E23}> NIL)
8: (COMPILER-HOOK #<PARSED-PROGRAM {1005412DF3}> #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects> :PROTOQUIL NIL :REWIRING-TYPE NIL)
9: ((LABELS TEST-LOGICAL-MATRIX-SANITY :IN TEST-LOGICAL-MATRIX-SANITY))
10: ((LABELS FIASCO::RUN-TEST-BODY :IN FIASCO::RUN-TEST-BODY-IN-HANDLERS))
11: (FIASCO::CALL-WITH-TEST-HANDLERS #<CLOSURE (LAMBDA NIL :IN FIASCO::RUN-TEST-BODY-IN-HANDLERS) {10054A320B}>)
12: (FIASCO::PRETTY-RUN-TEST #<test TEST-LOGICAL-MATRIX-SANITY> #<FUNCTION (LABELS TEST-LOGICAL-MATRIX-SANITY :IN TEST-LOGICAL-MATRIX-SANITY) {2395148B}>)
13: ((LABELS #:BODY-SYM0 :IN TEST-LOGICAL-MATRIX-SANITY))
14: (TEST-LOGICAL-MATRIX-SANITY)
15: ((LABELS FIASCO-SUITES::CL-QUIL-TESTS :IN FIASCO-SUITES::CL-QUIL-TESTS))
16: ((LABELS FIASCO::RUN-TEST-BODY :IN FIASCO::RUN-TEST-BODY-IN-HANDLERS))
17: (FIASCO::CALL-WITH-TEST-HANDLERS #<CLOSURE (LAMBDA NIL :IN FIASCO::RUN-TEST-BODY-IN-HANDLERS) {100549A04B}>)
18: (FIASCO::PRETTY-RUN-TEST #<test FIASCO-SUITES::CL-QUIL-TESTS :tests 170> #<FUNCTION (LABELS FIASCO-SUITES::CL-QUIL-TESTS :IN FIASCO-SUITES::CL-QUIL-TESTS) {2394989B}>)
19: ((LABELS #:BODY-SYM1 :IN FIASCO-SUITES::CL-QUIL-TESTS))
20: (FIASCO-SUITES::CL-QUIL-TESTS)
21: (RUN-SUITE-TESTS #<test FIASCO-SUITES::CL-QUIL-TESTS :tests 170> :VERBOSE NIL :STREAM #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDOUT* {10000062B3}> :INTERACTIVE T)
22: (RUN-TESTS :CL-QUIL-TESTS :DESCRIBE-FAILURES T :VERBOSE NIL :STREAM #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDOUT* {10000062B3}> :INTERACTIVE T)
23: (RUN-CL-QUIL-TESTS :VERBOSE NIL :HEADLESS NIL)
24: ((SB-PCL::EMF ASDF/ACTION:PERFORM) #<unused argument> #<unused argument> #<ASDF/LISP-ACTION:TEST-OP > #<ASDF/SYSTEM:SYSTEM "cl-quil-tests">)
25: ((LAMBDA NIL :IN ASDF/ACTION:CALL-WHILE-VISITING-ACTION))
26: ((:METHOD ASDF/ACTION:PERFORM-WITH-RESTARTS :AROUND (T T)) #<ASDF/LISP-ACTION:TEST-OP > #<ASDF/SYSTEM:SYSTEM "cl-quil-tests">) [fast-method]
27: ((:METHOD ASDF/PLAN:PERFORM-PLAN (T)) #<ASDF/PLAN:SEQUENTIAL-PLAN {10028DD3F3}>) [fast-method]
28: ((FLET SB-C::WITH-IT :IN SB-C::%WITH-COMPILATION-UNIT))
29: ((:METHOD ASDF/PLAN:PERFORM-PLAN :AROUND (T)) #<ASDF/PLAN:SEQUENTIAL-PLAN {10028DD3F3}>) [fast-method]
30: ((:METHOD ASDF/OPERATE:OPERATE (ASDF/OPERATION:OPERATION ASDF/COMPONENT:COMPONENT)) #<ASDF/LISP-ACTION:TEST-OP > #<ASDF/SYSTEM:SYSTEM "cl-quil"> :PLAN-CLASS NIL :PLAN-OPTIONS NIL) [fast-method]
31: ((SB-PCL::EMF ASDF/OPERATE:OPERATE) #<unused argument> #<unused argument> #<ASDF/LISP-ACTION:TEST-OP > #<ASDF/SYSTEM:SYSTEM "cl-quil">)
32: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
33: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) #<ASDF/LISP-ACTION:TEST-OP > #<ASDF/SYSTEM:SYSTEM "cl-quil">) [fast-method]
34: ((SB-PCL::EMF ASDF/OPERATE:OPERATE) #<unused argument> #<unused argument> ASDF/LISP-ACTION:TEST-OP :CL-QUIL)
35: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
36: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) ASDF/LISP-ACTION:TEST-OP :CL-QUIL) [fast-method]
37: (ASDF/SESSION:CALL-WITH-ASDF-SESSION #<CLOSURE (LAMBDA NIL :IN ASDF/OPERATE:OPERATE) {100285194B}> :OVERRIDE T :KEY NIL :OVERRIDE-CACHE T :OVERRIDE-FORCING NIL)
38: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
39: (ASDF/SESSION:CALL-WITH-ASDF-SESSION #<CLOSURE (LAMBDA NIL :IN ASDF/OPERATE:OPERATE) {1002798E0B}> :OVERRIDE NIL :KEY NIL :OVERRIDE-CACHE NIL :OVERRIDE-FORCING NIL)
40: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) ASDF/LISP-ACTION:TEST-OP :CL-QUIL) [fast-method]
41: (ASDF/OPERATE:TEST-SYSTEM :CL-QUIL)
42: (SB-INT:SIMPLE-EVAL-IN-LEXENV (ASDF/OPERATE:TEST-SYSTEM :CL-QUIL) #<NULL-LEXENV>)
43: (EVAL (ASDF/OPERATE:TEST-SYSTEM :CL-QUIL))
44: (SB-IMPL::PROCESS-EVAL/LOAD-OPTIONS ((:LOAD . "/Users/mappleby/quicklisp/setup.lisp") (:EVAL . "(push (truename \".\") asdf:*central-registry*)") (:EVAL . "(push :drakma-no-ssl *features*)") (:EVAL . "(push (truename \"../\") ql:*local-project-directories*)") (:EVAL . "(ql:quickload :cl-quil-tests)") (:EVAL . "(asdf:test-system :cl-quil)") (:EVAL . "(ql:quickload :quilc-tests)") (:EVAL . "(asdf:test-system :quilc)") (:QUIT)))
45: (SB-IMPL::TOPLEVEL-INIT)
46: ((FLET SB-UNIX::BODY :IN SB-EXT:SAVE-LISP-AND-DIE))
47: ((FLET "WITHOUT-INTERRUPTS-BODY-14" :IN SB-EXT:SAVE-LISP-AND-DIE))
48: ((LABELS SB-IMPL::RESTART-LISP :IN SB-EXT:SAVE-LISP-AND-DIE))

unhandled condition in --disable-debugger mode, quitting
;
; compilation unit aborted
;   caught 1 fatal ERROR condition
make: *** [test] Error 1

@appleby appleby changed the title zap-info broken on SBCL 1.5.6 Memory corruption issues on SBCL 1.5.6 Aug 31, 2019
@appleby
Copy link
Contributor Author

appleby commented Sep 1, 2019

Expanded backtrace of the above test failure with CL-QUIL:APPLY-TRANSLATION-COMPILERS compiled with max debug settings.

Unhandled memory fault at #x0.
   [Condition of type SB-SYS:MEMORY-FAULT-ERROR]

Restarts:
 0: [TRY-NEXT-COMPILER] Ignore this error and try the next compiler in the list.
 1: [CONTINUE] Skip the rest of the test CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY and continue by returning (values)
 2: [RETEST] Rerun the test CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY
 3: [CONTINUE-WITHOUT-DEBUGGING] Turn off debugging for this test session and invoke the first CONTINUE restart
 4: [CONTINUE-WITHOUT-DEBUGGING-ERRORS] Do not stop at unexpected errors for the rest of this test session and continue by invoking the first CONTINUE restart
 5: [CONTINUE-WITHOUT-DEBUGGING-ASSERTIONS] Do not stop at failed assertions for the rest of this test session and continue by invoking the first CONTINUE restart
 --more--

Backtrace:
  0: (SB-VM::FUNCALLABLE-INSTANCE-TRAMP)
      [No Locals]
  1: ((LABELS CL-QUIL::TRY-COMPILER :IN CL-QUIL::APPLY-TRANSLATION-COMPILERS) 1)
      Locals:
        CL-QUIL::COMPILATION-METHOD = 1
        CL-QUIL::CONTEXT = 59764212
        CL-QUIL:INSTRUCTION = "0"
  2: ((LABELS CL-QUIL::TRY-COMPILER :IN CL-QUIL::APPLY-TRANSLATION-COMPILERS) CL-QUIL::SWAP-TO-NATIVE-SWAPS)
      Locals:
        CL-QUIL::COMPILATION-METHOD = CL-QUIL::SWAP-TO-NATIVE-SWAPS
        CL-QUIL::CONTEXT = #S(CL-QUIL::COMPILATION-CONTEXT :AQVM NIL :CHIP-SPECIFICATION #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects>)
        CL-QUIL:INSTRUCTION = #<CONTROLLED FORKED Y 2 1 0>
  3: (CL-QUIL::APPLY-TRANSLATION-COMPILERS #<CONTROLLED FORKED Y 2 1 0> #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects> NIL)
      Locals:
        CHIP-SPEC = #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects>
        CONTEXT = #S(CL-QUIL::COMPILATION-CONTEXT :AQVM NIL :CHIP-SPECIFICATION #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects>)
        #:G69 = #(CL-QUIL::SWAP-TO-NATIVE-SWAPS CL-QUIL::CNOT-TO-NATIVE-CNOTS CL-QUIL::CZ-TO-NATIVE-CZS CL-QUIL::CCNOT-TO-CNOT CL-QUIL::PHASE-TO-RZ CL-QUIL::UCR-COMPILER-TO-CZ ...)
        HARDWARE-OBJECT = NIL
        SB-INT:INDEX = 0
        INSTRUCTION = #<CONTROLLED FORKED Y 2 1 0>
  4: (CL-QUIL::DEQUEUE-GATE-APPLICATION #<CONTROLLED FORKED Y 2 1 0> NIL)
      Locals:
        DIRTY-FLAG = NIL
        DRY-RUN-ESCAPE = NIL
        INSTR = #<CONTROLLED FORKED Y 2 1 0>
        SB-C::OBJECT = #S(CL-QUIL::TEMPORAL-ADDRESSER ..)
        PARTIAL-2Q-INSTRS = NIL
        READY-2Q-INSTRS = NIL
  5: (CL-QUIL::DEQUEUE-LOGICAL-TO-PHYSICAL :DRY-RUN NIL)
      Locals:
        #:.DEFAULTING-TEMP. = NIL
        2Q-INSTRS-PARTIALLY-ASSIGNED = NIL
        2Q-INSTRS-READY-FOR-SCHEDULING = NIL
        DIRTY-FLAG = NIL
        DRY-RUN-ESCAPE = NIL
      Catch-tags:
        CL-QUIL::DRY-RUN-SUCCEEDED
  6: (CL-QUIL::DO-GREEDY-TEMPORAL-ADDRESSING (#<CONTROLLED FORKED Y 2 1 0>) #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects> :INITIAL-REWIRING #S(CL-QUIL::REWIRING :L2P #(NIL NIL NIL) :P2L #(NIL NIL NIL)) :US..
      Locals:
        CHIP-SPEC = #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects>
        #:G16 = T
        INITIAL-REWIRING = #S(CL-QUIL::REWIRING :L2P #(NIL NIL NIL) :P2L #(NIL NIL NIL))
        INSTRS = (#<CONTROLLED FORKED Y 2 1 0>)
        SB-C::OBJECT = #S(CL-QUIL::TEMPORAL-ADDRESSER ..)
        REWIRINGS-TRIED = NIL
  7: ((LABELS CL-QUIL::PROCESS-BLOCK :IN CL-QUIL:COMPILER-HOOK) #<CL-QUIL::BASIC-BLOCK ENTRY-BLK-637 len:1 in:0 out:term {100A797A23}> NIL)
      Locals:
        CL-QUIL::BLK = #<CL-QUIL::BASIC-BLOCK ENTRY-BLK-637 len:1 in:0 out:term {100A797A23}>
        CL-QUIL::REGISTRANT = NIL
  8: (CL-QUIL:COMPILER-HOOK #<CL-QUIL:PARSED-PROGRAM {1009D6F5E3}> #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects> :PROTOQUIL NIL :REWIRING-TYPE NIL)
      Locals:
        #:.DEFAULTING-TEMP. = NIL
        BLOCK-STACK = NIL
        CFG = #<CL-QUIL::CFG of 1 block {100A797B13}>
        CHIP-SPECIFICATION = #<CL-QUIL::CHIP-SPECIFICATION of 3:2 objects>
        #:N-SUPPLIED-0 = 0
        PARSED-PROGRAM = #<CL-QUIL:PARSED-PROGRAM {1009D6F5E3}>
        PROTOQUIL = NIL
        TOPOLOGICAL-SWAPS = 0
        UNPRESERVED-DURATION = 0
  9: ((LABELS CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY :IN CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY))
      Locals:
        CL-QUIL-TESTS::ACTUAL = #S(MAGICL:MATRIX :ROWS 8 :COLS 8 :DATA-TYPE MAGICL:Z :STORAGE-TYPE MAGICL::GE :DATA #(#C(1.0d0 0.0d0) #C(0.0d0 0.0d0) #C(0.0d0 0.0d0) #C(0.0d0 0.0d0) #C(0.0d0 0.0d0) #C(0.0d0 0.0d0) ...))
        CL-QUIL-TESTS::EXPECTED = #S(MAGICL:MATRIX :ROWS 8 :COLS 8 :DATA-TYPE MAGICL:Z :STORAGE-TYPE MAGICL::GE :DATA #(#C(1.0d0 0.0d0) #C(0.0d0 0.0d0) #C(0.0d0 0.0d0) #C(0.0d0 0.0d0) #C(0.0d0 0.0d0) #C(0.0d0 0.0d0) ...))
 10: ((LABELS FIASCO::RUN-TEST-BODY :IN FIASCO::RUN-TEST-BODY-IN-HANDLERS))
 11: (FIASCO::CALL-WITH-TEST-HANDLERS #<CLOSURE (LAMBDA NIL :IN FIASCO::RUN-TEST-BODY-IN-HANDLERS) {1001FABE6B}>)
 12: (FIASCO::PRETTY-RUN-TEST #<test CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY> #<FUNCTION (LABELS CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY :IN CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY) {23A3D6CB}>)
 13: ((LABELS #:BODY-SYM0 :IN CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY))
 14: (CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY)
 15: (FIASCO:RUN-SUITE-TESTS #<test CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY> :VERBOSE NIL :STREAM #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-OUTPUT* {1001510B83}> :INTERACTIVE T)
 16: (FIASCO:RUN-TESTS CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY :DESCRIBE-FAILURES T :VERBOSE NIL :STREAM NIL :INTERACTIVE T)
 17: (SB-INT:SIMPLE-EVAL-IN-LEXENV (FIASCO:RUN-TESTS (QUOTE CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY) :INTERACTIVE T) #<NULL-LEXENV>)
 18: (EVAL (FIASCO:RUN-TESTS (QUOTE CL-QUIL-TESTS::TEST-LOGICAL-MATRIX-SANITY) :INTERACTIVE T))
 --more--

@notmgsk
Copy link
Member

notmgsk commented Sep 1, 2019

Weeeeeeeeird. But fun.

@appleby
Copy link
Contributor Author

appleby commented Sep 1, 2019

A head-scratcher to be sure.

@appleby
Copy link
Contributor Author

appleby commented Sep 1, 2019

Looks like something fishy going on with the combination of define-compiler + funcall

QUIL> (funcall 'swap-to-native-swaps
         (nth-instr 0 (parse-quil "CONTROLLED FORKED Y 2 1 0"))
         :context (make-compilation-context
                   :chip-specification (build-8q-chip)))

; Evaluation aborted on #<SB-SYS:MEMORY-FAULT-ERROR {100CB7C193}>.

If I just call the compiler directly rather than funcalling the symbol, I get a compiler-does-not-apply condition, as expected.

QUIL> (swap-to-native-swaps (nth-instr 0 (parse-quil "CONTROLLED FORKED Y 2 1 0"))
                      :context (make-compilation-context
                                :chip-specification (build-8q-chip)))

; Evaluation aborted on #<COMPILER-DOES-NOT-APPLY {1002C5C003}>.

Also works If I explicitly funcall the fdefinition

QUIL> (funcall (fdefinition 'swap-to-native-swaps)
         (nth-instr 0 (parse-quil "CONTROLLED FORKED Y 2 1 0"))
         :context (make-compilation-context
                   :chip-specification (build-8q-chip)))
; Evaluation aborted on #<COMPILER-DOES-NOT-APPLY {100AC40943}>.

Replacing fdefinition with symbol-function in the above also works...

@appleby
Copy link
Contributor Author

appleby commented Sep 1, 2019

The hyperspec entry for funcall says:

funcall applies function to args. If function is a symbol, it is coerced to a function as if by finding its functional value in the global environment.

And also

An error of type undefined-function should be signaled if function is a symbol that does not have a global definition as a function or that has a global definition as a macro or a special operator.

You'd think that the fact the symbol-function and fdefinition return the expected function would be enough to satisfy SBCL... something fun to look into :-)

@appleby
Copy link
Contributor Author

appleby commented Sep 3, 2019

Kudos to @notmgsk for spotting this SBCL commit which looks like a likely candidate:

sbcl/sbcl@1f892df

@appleby
Copy link
Contributor Author

appleby commented Sep 3, 2019

A couple more examples:

(defclass foo ()
  ((%function :initarg :function :reader foo-%function))
  (:metaclass closer-mop:funcallable-standard-class))

(defmethod initialize-instance :after ((f foo) &key)
  (closer-mop:set-funcallable-instance-function f (foo-%function f)))

(setf (fdefinition 'zonk) (make-instance 'foo :function (lambda (y) y)))
(funcall 'zonk 3)
; Evaluation aborted on #<SB-SYS:MEMORY-FAULT-ERROR {100238DA13}>.

This fails:

(let ((g (build-gate "CAN" '(1d0 0d0 0d0) 1 0)))
  (nearest-circuit-of-depth-0 g))

This doesn't:

(nearest-circuit-of-depth-0 (build-gate "CAN" '(1d0 0d0 0d0) 1 0))

@appleby
Copy link
Contributor Author

appleby commented Sep 3, 2019

All the define-compiler + funcall issues mentioned above appear to have been fixed in the following SBCL commit (phew):

https://sourceforge.net/p/sbcl/sbcl/ci/550c4d23c77cc670fb95d7216e3c6d493bbd76eb/

@appleby
Copy link
Contributor Author

appleby commented Sep 4, 2019

Closing this since the bulk of the memory corruption issues were resolved by the above mentioned SBCL commit.

Opened #407 to track fixing ZAP-INFO on SBCL 1.5.6+

@appleby appleby closed this as completed Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants