Skip to content

Interpreter Crash - strange typecasting? #712

@fosskers

Description

@fosskers

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions