Interpreter Crash - strange typecasting?
Hi there, I'm hitting a strange crash involving a certain parser function of mine.
Symptoms:
- Tests pass on other compilers.
- ABCL: Tests stop (not just marked as failure) during testing of XML parsers when run from the REPL.
- ABCL: Usual "send to REPL" editor commands on the crashing function also fail and the debugger does not open:
(p:parse #'open-tag "<hello>") - ABCL: Directly typing that command into the REPL crashes ABCL entirely.
- ABCL: Running tests from the command line gives an actual JVM trace:
Exception in thread "interpreter" java.lang.ClassCastException: class org.armedbear.lisp.SimpleString cannot be cast to class org.armedbear.lisp.Fixnum (org.armedbear.lisp.SimpleString and org.armedbear.lisp.Fixnum are in unnamed module of loader 'app')
- Using step debugging I can determine that all the actual parsing and post-processing within the parser actually succeed. It seems like it's somehow crashing while it's returning, or possibly while it's typechecking its return values.
The type declaration of the function is this:
(fn open-tag (maybe (or element cons p::char-string)))
which uses the following macros:
(deftype char-string ()
'(simple-array character (*)))
(defmacro fn (name type)
"A shorthand for declaiming function types."
`(declaim (ftype ,type ,name)))
(deftype maybe (res)
"A parser that might fail."
`(function (fixnum) (values (or ,res (member :fail)) fixnum)))
The latter is a signature common to most parsers in my library. Notice the fixnums. All other non-XML tests pass without issue.
Any idea what might be happening here, or how I can further debug? Thank you.
Just from quickly eyeballing your report, note that errors like
(org.armedbear.lisp.SimpleString and org.armedbear.lisp.Fixnum are in unnamed module of loader 'app')
come from the tightening of class loading rules in the openjdk-11 module system. AFAIK, such problems are highly dependent on the openjdk being used, and can be addressed be whitelisting the appropriate module via runtime switches like in https://github.com/armedbear/abcl/blob/36a243efb86c3667d2f1814ad3a457712f4f92c4/ci/create-abcl-properties.bash#L16.
Not sure this is the only problem you are facing, but trying to figure out how to relax the restriction on the "unnamed module of loader 'app'" would be a first step.
Can you provide the values returned by (lisp-implementation-version) so I can try to reproduce?
Thanks, here's my version info:
"1.9.2"
"OpenJDK_64-Bit_Server_VM-Arch_Linux-24.0.2"
"amd64-Linux-6.16.3-arch1-1"