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

Lem hangs when redefining struct as class #1453

Open
anlsh opened this issue Jul 23, 2024 · 4 comments
Open

Lem hangs when redefining struct as class #1453

anlsh opened this issue Jul 23, 2024 · 4 comments

Comments

@anlsh
Copy link
Contributor

anlsh commented Jul 23, 2024

Steps to reproduce

Put this some file

;; foo.lisp
(defstruct foo)
(defclass foo () ())

Then open it with latest main (I tested with 35e010f4de35d7713f632dadbf82be31176bcf32), and M-x lisp-compile-and-load-file, or evaluate both forms independently, or whatever. Lem will hang.


To be clear, sbcl doesn't think that this is a valid sequence of forms, and breaks accordingly

$ sbcl --load /tmp/foo.lisp 
This is SBCL 2.1.11.debian, 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.
While evaluating the form starting at line 3, column 0
  of #P"/tmp/foo.lisp":

debugger invoked on a SB-PCL::METAOBJECT-INITIALIZATION-VIOLATION in thread
#<THREAD "main thread" RUNNING {1001834103}>:
  Cannot CHANGE-CLASS objects into CLASS metaobjects.
See also:
  AMOP, Initialization of Class Metaobjects

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY   ] Retry EVAL of current toplevel form.
  1: [CONTINUE] Ignore error and continue loading file "/tmp/foo.lisp".
  2: [ABORT   ] Abort loading file "/tmp/foo.lisp".
  3:            Ignore runtime option --load "/tmp/foo.lisp".
  4:            Skip rest of --eval and --load options.
  5:            Skip to toplevel READ/EVAL/PRINT loop.
  6: [EXIT    ] Exit SBCL (calling #'EXIT, killing the process).

(SB-PCL::CHANGE-CLASS-TO-METAOBJECT-VIOLATION CLASS NIL ((:AMOP :INITIALIZATION CLASS)))
0]

But it offers appropriate restarts so it's obiously recoverable. Hanging lem is bad: how can we fix this? I'm willing to go dig around given some initial pointers

@johnlorentzson
Copy link
Contributor

It appears sending a SIGTERM (via C-c in the terminal) after it freezes causes it to display a memory fault error and it took a while after that to reach ldb. Strange.
image

@cxxxr
Copy link
Member

cxxxr commented Jul 24, 2024

Although I haven't investigated anything yet, I suspect that the cause of the hang-up is the communication part with micros.

@anlsh
Copy link
Contributor Author

anlsh commented Sep 5, 2024

@cxxxr Where do I start digging on this? If you can give me some pointers on the basics (streaming micros logs to a console, say) then I can give debugging a shot

@cxxxr
Copy link
Member

cxxxr commented Sep 5, 2024

@anlsh I often print debug to a specific file (e.g. /tmp/foo.log).

(defun dbg (fmt &rest args)
  (with-open-file (stream "/tmp/foo.log" :direction :output :if-exists :append)
    (apply #'format stream fmt args)
    (terpri stream)))

I also think the problem lies in the part where it is compiled and loaded, so I will start the print debug from there.

https://github.com/lem-project/micros/blob/9fc7f1e5b0dbf1b9218a3f0aca7ed46e90aa86fd/micros.lisp#L2537

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

3 participants