cosmos72 / stmx

High performance Transactional Memory for Common Lisp
http://stmx.org/
244 stars 14 forks source link

sb-vm::emit-skip does not exist in sbcl 2.0.0 #17

Closed lisp closed 4 years ago

lisp commented 4 years ago

the following error occurs caught ERROR: ; READ error during COMPILE-FILE: ;
; Lock on package SB-VM violated when interning EMIT-SKIP while in package ; SB-X86-64-ASM.

as a workaround, it appears possible to define the function with #'sb-assem::%emit-skip as its value.

cosmos72 commented 4 years ago

Thanks for the report.

There must be some strange interaction with sbcl 2.0.0, because sbcl has its own internal definitions of xbegin xend xabort and xtest since at least one year, and the conditional #-#.(stmx.asm::compile-if-instruction-defined 'xbegin) should detect them, thus the code that fails should not be compiled at all.

I will investigate why xbegin availability is not detected

cosmos72 commented 4 years ago

I could not reproduce the problem - neither with the latest stmx from github (commit c23336612b59a49f0465e047795059d78e406131) nor with stmx auto-downloaded by quicklisp (package stmx-stable-4d915e33-git).

Which version of stmx are you using?

lisp commented 4 years ago
@de10 /development/source/library/com/github/cosmos72/stmx # find . -name '*.lisp' | while read file; do fgrep -H sb-vm::emit-skip $file; done                          
./asm/x86-32,64-insts.lisp:       (sb-vm::emit-skip segment 4 0))))
@de10 /development/source/library/com/github/cosmos72/stmx # git log | head -n 5
commit c23336612b59a49f0465e047795059d78e406131
Author: Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com>
Date:   Sat Sep 7 22:43:59 2019 +0200

    add missing function (stmx.util:map-ghash hash func)
@de10 /development/source/library/com/github/cosmos72/stmx # find . -name '*.lisp' | while read file; do fgrep -H sb-vm::emit-skip $file; done                          
./asm/x86-32,64-insts.lisp:       (sb-vm::emit-skip segment 4 0))))
@de10 /development/source/library/com/github/cosmos72/stmx # which sbcl
/opt/sbcl/2.0.0/bin/sbcl
@de10 /development/source/library/com/github/cosmos72/stmx # sbcl
This is SBCL 2.0.0, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under                                                                                                     
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (apropos "EMIT-SKIP")
SB-ASSEM::%EMIT-SKIP (fbound)
* (find-symbol "EMIT-SKIP" :sb-vm)
NIL
NIL
* @de10 /development/source/library/com/github/cosmos72/stmx # ls -l /opt/sbcl/2.0.0/bin/sbcl
-rwxr-xr-x 1 root root 1688896 Jan  7 18:10 /opt/sbcl/2.0.0/bin/sbcl
cosmos72 commented 4 years ago

Good, you have a copy of the latest stmx from github, plus sbcl 2.0.0.

Did you also check that loading stmx from sbcl REPL (I guess using quicklisp) did not download and use an old stmx version from quicklisp repository?

If that's the case, the quick solution is to eval (ql:update-all-dists) at REPL to force updating the list of libraries known to quicklisp. The full solution is to additionally convince quicklisp to use your local copy of stmx instead of its own, for example by placing stmx (or a symlink to it) in $HOME/common-lisp/

In any case, the commands

rm -fr "$HOME/.cache/common-lisp"
find "$HOME/quicklisp" -name '*stmx*' -exec rm -frv '{}' +

followed by a full log produced while loading stmx from sbcl would help understanding where the faulty stmx is coming from.

lisp commented 4 years ago

i never use quicklisp. i just built it the same way i have been building it for four years with asdf.

so far as i can see, the symbol is missing. what effect do you seek to get me to reproduce?

cosmos72 commented 4 years ago

Yes, the symbol SB-VM::EMIT-SKIP is missing, and it has been missing since sbcl 1.4.10 - see https://github.com/cosmos72/stmx/issues/14

The version of stmx you have locally should not use that symbol, because it's protected by #-#.(stmx.asm::compile-if-instruction-defined 'xbegin)

What I do not understand is how/why such conditional fails. My first guess was that an older version of stmx was lingering somewhere, and was being compiled instead. This can happen easily if you use quicklisp, but since you do not use it, it should be excluded.

Can you please eval (stmx.asm::compile-if-instruction-defined 'xbegin) at REPL after the error, and post the result?

lisp commented 4 years ago

i walked back through the build process and i observe that at when the problem first arose i had compiled with the available 1.4.3 x86 sbcl binary because i had not yet built the 2.0.0 from source. could that be the source of the problem?

cosmos72 commented 4 years ago

There can be problems only if you create .fasl files with one version of sbcl then load them into a different version (for example because they are cached by asdf). If you avoid this case, each sbcl will compile stmx from sources thus having used a different compiler in the past cannot be a problem.

The output of eval (stmx.asm::compile-if-instruction-defined 'xbegin) is one step in clarifying this kind of issues.

lisp commented 4 years ago

but it would have been when i used the pre 2.0.0 binary. in order to get that to complete, i changed the stmx package definition and then continued to use that change without looking at whether it actually mattered for 2.0.0. my mistake.

cosmos72 commented 4 years ago

Understood. Does restoring the original sources solve the issue?

lisp commented 4 years ago

yes. i have built using sbcl 2.0.0 with stmx@c233366.
the problem was limited to trying to use the older sbcl version.