lem-project / lem

Common Lisp editor/IDE with high expansibility
http://lem-project.github.io/
MIT License
2.4k stars 178 forks source link

LEM error #1178

Closed rpx99 closed 11 months ago

rpx99 commented 11 months ago

I start a repl and enter:

(funcall (lambda (x) (+ x 100)) 2)

When I mistakenly miss the 2, i.e.

(funcall (lambda (x) (+ x 100)) )

the error occurs.

SDL Error (#SDL-SURFACE {#X00000000}>): Text h

LEM freezes "evaluating" and takes more and more CPU.

Sasanidas commented 11 months ago

I'm sorry but I can't reproduce, I compiled Lem with the last commit, launch the editor and then call the command slime-self-connect. Then enter the input that you provide, what it happens it that it goes into the debugger (which makes sense)

db

rpx99 commented 11 months ago

Hmm..strange. I'll try to find out more.

error memory

rpx99 commented 11 months ago

When LEM tries to start the debugger it seems to start another process. But there is an infinite loop that creates more and more threads / processes (?) in the background ?

At least it looks to me in htop like something like that is happening. That explains more and more resources are taken by the CPU. lem_taking_it_all

Sasanidas commented 11 months ago

Maybe we are using a different sdl2 version? That's quite an odd behaviour

rpx99 commented 11 months ago

tron$ doas pkg_info sdl2 Information for inst:sdl2-2.28.5

Comment: cross-platform multimedia library

Required by: ffmpeg-4.4.4p2v1 sdl2-image-2.6.3 sdl2-ttf-2.20.2p2

sbcl:

(:SDL2-TTF)

(:SDL2-IMAGE)

`

rpx99 commented 11 months ago

Only need to call

inspect

to make this happen:

screenshot_2023-12-11_16-41-12

Is it something like a null pointer in sdl2-ttf ?

Sasanidas commented 11 months ago

Maybe the version is sdl2 is too high?

In my case, the output of the above command is:

CL-USER> (sdl2-ttf:linked-version)
2
0
15
CL-USER> 
rpx99 commented 11 months ago
[20:01:38] lem-sdl2 main.lisp (delete-view sdl2) - lem-if:delete-view [20:01:38] lem-sdl2 main.lisp (display-width sdl2) - lem-if:display-width [20:01:38] lem-sdl2 main.lisp (display-height sdl2) - lem-if:display-height [20:01:38] lem-sdl2 main.lisp (display-height sdl2) - lem-if:display-height [20:01:38] lem-sdl2 main.lisp (make-view sdl2) - lem-if:make-view LEM-SDL2::WINDOW: # LEM-SDL2::X: 1 LEM-SDL2::Y: 16 LEM-SDL2::WIDTH: 47 LEM-SDL2::HEIGHT: 1 LEM-SDL2::USE-MODELINE: NIL [20:01:38] lem-sdl2 main.lisp (display-width sdl2) - lem-if:display-width [20:01:38] lem-sdl2 main.lisp (display-height sdl2) - lem-if:display-height [20:01:38] lem-sdl2 main.lisp (display-height sdl2) - lem-if:display-height [20:01:38] lem-sdl2 main.lisp (set-view-size sdl2) - lem-if:set-view-size LEM-SDL2::VIEW: # LEM-SDL2::WIDTH: 47 LEM-SDL2::HEIGHT: 1 [20:01:38] lem-sdl2 main.lisp (set-view-pos sdl2) - lem-if:set-view-pos LEM-SDL2::VIEW: # LEM-SDL2::X: 1 LEM-SDL2::Y: 16 [20:01:38] lem-sdl2 main.lisp (redraw-view-before sdl2) - lem-if:redraw-view-before LEM-SDL2::VIEW: # [20:01:38] lem-sdl2 main.lisp (get-background-color sdl2) - lem-if:get-background-color [20:01:38] lem-sdl2 main.lisp (get-background-color sdl2) - lem-if:get-background-color [20:01:38] lem-sdl2 main.lisp (redraw-view-after sdl2) - lem-if:redraw-view-after LEM-SDL2::VIEW: # [20:01:38] lem-sdl2 main.lisp (update-display sdl2) - lem-if:update-display [20:01:38] lem-sdl2 main.lisp (will-update-display sdl2) - will-update-display [20:01:38] lem-sdl2 main.lisp (display-width sdl2) - lem-if:display-width [20:01:38] lem-sdl2 main.lisp (display-height sdl2) - lem-if:display-height [20:01:38] lem-sdl2 main.lisp (redraw-view-before sdl2) - lem-if:redraw-view-before LEM-SDL2::VIEW: # [20:01:38] lem-sdl2 main.lisp (redraw-view-after sdl2) - lem-if:redraw-view-after LEM-SDL2::VIEW: # [20:01:38] lem-sdl2 main.lisp (redraw-view-before sdl2) - lem-if:redraw-view-before LEM-SDL2::VIEW: # [20:01:38] lem-sdl2 main.lisp (redraw-view-after sdl2) - lem-if:redraw-view-after LEM-SDL2::VIEW: # [20:01:38] lem-sdl2 main.lisp (redraw-view-before sdl2) - lem-if:redraw-view-before LEM-SDL2::VIEW: # [20:01:38] lem-sdl2 main.lisp (redraw-view-after sdl2) - lem-if:redraw-view-after LEM-SDL2::VIEW: # [20:01:38] lem-sdl2 main.lisp (redraw-view-before sdl2) - lem-if:redraw-view-before LEM-SDL2::VIEW: # [20:01:38] lem-core physical-line.lisp (call-with-display-error) - SDL Error (#): Text has zero width Backtrace for: # 0: ((LAMBDA NIL :IN UIOP/IMAGE:PRINT-BACKTRACE)) 1: ((FLET "THUNK" :IN UIOP/STREAM:CALL-WITH-SAFE-IO-SYNTAX)) 2: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #) 3: (UIOP/STREAM:CALL-WITH-SAFE-IO-SYNTAX # :PACKAGE :CL) 4: ((FLET "log-stmt1" :IN LEM-CORE::CALL-WITH-DISPLAY-ERROR) #) 5: ((LAMBDA (STREAM LOG4CL-IMPL::FMT-INFO LOG4CL-IMPL::LOGGER LOG4CL-IMPL::LOG-LEVEL LOG4CL-IMPL::LOG-FUNC) :IN "/home/rpx/common-lisp/lem/.qlot/dists/quicklisp/software/log4cl-20230618-git/src/appender/pattern-layout.lisp") # # # # #) 6: ((LAMBDA (STREAM LOG4CL-IMPL::LOGGER LOG4CL-IMPL::LEVEL LOG4CL-IMPL::LOG-FUNC) :IN LOG4CL-IMPL::COMPILE-PATTERN-FORMAT) # # 2 #) 7: ((FLET "WITH-PRETTY-STREAM0" :IN SB-PRETTY::CALL-LOGICAL-BLOCK-PRINTER) #) 8: (SB-PRETTY::CALL-LOGICAL-BLOCK-PRINTER # # NIL NIL "" NIL) 9: ((LAMBDA (STREAM LOG4CL-IMPL::FMT-INFO LOG4CL-IMPL::LOGGER LOG4CL-IMPL::LOG-LEVEL LOG4CL-IMPL::LOG-FUNC LOG4CL-IMPL::WRAP) :IN "/home/rpx/common-lisp/lem/.qlot/dists/quicklisp/software/log4cl-20230618-git/src/appender/pattern-layout.lisp") # # # 2 # #) 10: ((LAMBDA (STREAM LOG4CL-IMPL::LOGGER LOG4CL-IMPL::LEVEL LOG4CL-IMPL::LOG-FUNC) :IN LOG4CL-IMPL::COMPILE-PATTERN-FORMAT) # # 2 #) 11: ((:METHOD LOG4CL-IMPL:LAYOUT-TO-STREAM (LOG4CL-IMPL:PATTERN-LAYOUT T T T T)) # # # 2 #) [fast-method] 12: ((:METHOD LOG4CL-IMPL:APPENDER-DO-APPEND (LOG4CL-IMPL::FIXED-STREAM-APPENDER-BASE T T T)) # # 2 #) [fast-method] 13: ((SB-PCL::EMF LOG4CL-IMPL:APPENDER-DO-APPEND) # # # # 2 #) 14: ((FLET "WITHOUT-INTERRUPTS-BODY-11" :IN SB-THREAD::CALL-WITH-RECURSIVE-LOCK)) 15: (SB-THREAD::CALL-WITH-RECURSIVE-LOCK # # T NIL) 16: ((:METHOD LOG4CL-IMPL:APPENDER-DO-APPEND :AROUND (LOG4CL-IMPL:SERIALIZED-APPENDER T T T)) # # 2 #) [fast-method] 17: ((LABELS LOG4CL-IMPL::LOG-TO-LOGGER-APPENDERS :IN LOG4CL-IMPL::LOG-WITH-LOGGER) # # 2 #) 18: ((LABELS LOG4CL-IMPL::LOG-TO-LOGGER-APPENDERS :IN LOG4CL-IMPL::LOG-WITH-LOGGER) # # 2 #) 19: ((LABELS LOG4CL-IMPL::LOG-TO-LOGGER-APPENDERS :IN LOG4CL-IMPL::LOG-WITH-LOGGER) # # 2 #) 20: (LOG4CL-IMPL::LOG-WITH-LOGGER # 2 # #) 21: ((LAMBDA (LEM-CORE::E) :IN LEM-CORE::CALL-WITH-DISPLAY-ERROR) #) 22: (SB-KERNEL::%SIGNAL #) 23: (ERROR SDL2-TTF::SDL-TTF-ERROR :RC # :STRING "Text has zero width") 24: (SDL2-TTF:RENDER-UTF8-BLENDED # #.(SB-SYS:INT-SAP #X53A8DFB4DE0) 255 255 255 0) 25: (LEM-SDL2/DRAWING::MAKE-TEXT-SURFACE # "🔒" # :EMOJI) 26: (LEM-SDL2/DRAWING::MAKE-TEXT-SURFACE-WITH-CACHE # "🔒" # :EMOJI) 27: ((:METHOD LEM-SDL2/DRAWING::GET-SURFACE :AROUND (T T)) # #) [fast-method] 28: ((:METHOD LEM-SDL2/DRAWING::DRAW-OBJECT (LEM-CORE/DISPLAY:TEXT-OBJECT T T T T)) # 27 420 # #) [fast-method] 29: (LEM-SDL2/DRAWING::REDRAW-PHYSICAL-LINE # # 0 399 (# # # # #) 21) 30: ((LAMBDA (LEM-SDL2/DRAWING::DISPLAY) :IN LEM-INTERFACE:RENDER-LINE-ON-MODELINE) #) 31: ((LAMBDA NIL :IN LEM-CORE:REDRAW-BUFFER)) 32: (LEM-CORE::CALL-WITH-DISPLAY-ERROR #) 33: (SDL2::HANDLE-MESSAGE (# . #S(TRIVIAL-CHANNELS:CHANNEL :QUEUE #S(TRIVIAL-CHANNELS.QUEUE:QUEUE :HEAD NIL :TAIL NIL) :Q-CONDITION # :Q-MUTEX #))) 34: (SDL2::GET-AND-HANDLE-MESSAGES) 35: ((LAMBDA NIL :IN LEM-SDL2::EVENT-LOOP)) 36: ((LAMBDA NIL :IN LEM-SDL2::CREATE-DISPLAY)) 37: (LEM-SDL2::CREATE-DISPLAY #) 38: ((LAMBDA NIL :IN LEM-INTERFACE:INVOKE)) 39: (SDL2::HANDLE-MESSAGE (#)) 40: (SDL2::SDL-MAIN-THREAD) 41: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LEM-CORE:LEM "--debug" "--log-filename" "lem.log") #) 42: (EVAL (LEM-CORE:LEM "--debug" "--log-filename" "lem.log")) 43: (SB-EXT:INTERACTIVE-EVAL (LEM-CORE:LEM "--debug" "--log-filename" "lem.log") :EVAL NIL) 44: (SB-IMPL::REPL-FUN NIL) 45: ((LAMBDA NIL :IN SB-IMPL::TOPLEVEL-REPL)) 46: (SB-IMPL::%WITH-REBOUND-IO-SYNTAX #) 47: (SB-IMPL::TOPLEVEL-REPL NIL) 48: (SB-IMPL::TOPLEVEL-INIT) 49: ((FLET SB-UNIX::BODY :IN SB-IMPL::START-LISP)) 50: ((FLET "WITHOUT-INTERRUPTS-BODY-3" :IN SB-IMPL::START-LISP)) 51: (SB-IMPL::%START-LISP)
rpx99 commented 11 months ago

Here the complete log file: lem.log

rpx99 commented 11 months ago

Okay, I find this symbol in src / lem / modeline.lisp:

(defun modeline-write-info (window) (let ((buffer (window-buffer window))) (cond ((buffer-read-only-p buffer) " 🔒 ") ((buffer-modified-p buffer) " * ") (t " "))))

There is a method:

(defmethod object-width ((drawing-object emoji-object) display) (* (display:display-char-width display) 2 (length (text-object-string drawing-object))))

in src / frontends / sdl2 / drawing.lisp

I wonder why it needs to get multiplied by the length of the text-object string of the drawing-object....

Suspect that it is 0...

rpx99 commented 11 months ago

I am at the right spot. If I replace the lock symbol in modeline with an ordinary Character the issue is gone and I get into the debugger. The replacement character is then shown in the modeline of the debugger.

Still looking into the real issue, i.e. why the lock symbol causes so much trouble...

Sasanidas commented 11 months ago

Interesting! Thanks for doing the research, indeed this seems like a very specific sdl2 problem... I'm not that familiar with, so I'll ping @cxxxr so he maybe help in this error.

rpx99 commented 11 months ago

In html here it looks "ok", but when I see my screenshot the LOCK character does not look properly (like an additional space is used as a second symbol).

@Sasanidas What does this show on your system?

debugger invoked on a SDL2-TTF::SDL-TTF-ERROR in thread

<THREAD "main thread" RUNNING {1001480003}>:

SDL Error (#<SDL-SURFACE {#X00000000}>): Text has zero width

Screenshot_2023-12-18_09-34-42

Sasanidas commented 11 months ago

For me, it works correctly, it doesn't trigger any error:

CL-USER> (make-string 1 :initial-element #\GREEK_CAPITAL_LETTER_SIGMA)
"Σ"
CL-USER> (SDL2-TTF:RENDER-UTF8-BLENDED (sdl2-ttf:open-font #P"/home/fermin/quicklisp/local-projects/lem/frontends/sdl2/resources/fonts/NotoColorEmoji.ttf" 15) (make-string 1 :initial-element #\GREEK_CAPITAL_LETTER_SIGMA) 255 255 255 0)
#<SDL2-FFI:SDL-SURFACE {#X7F8ABC00F210}>
CL-USER> (make-string 1 :initial-element #\LOCK)
"🔒"
CL-USER> (SDL2-TTF:RENDER-UTF8-BLENDED (sdl2-ttf:open-font #P"/home/fermin/quicklisp/local-projects/lem/frontends/sdl2/resources/fonts/NotoColorEmoji.ttf" 15) (make-string 1 :initial-element #\LOCK) 255 255 255 0)
#<SDL2-FFI:SDL-SURFACE {#X7F8ABC009F00}>

sdl2_lock

Sasanidas commented 11 months ago

(ignore the second line of t he screenshot, I just press enter with the path not fully changed)

rpx99 commented 11 months ago

Thanks a lot for testing!

A fresh installation with debian 12 works, too. Hmmm...

badmrfrosty commented 11 months ago

Hello,

I have the same problem as rpx99 : pic-selected-231218-1954-14

When I entered the command, I got the same SDL error as well but it quickly disappeared, that's why it does not appear on the screenshot

SDL Error (#<SDL-SURFACE {#X00000000}>): Text has zero width

rpx99 commented 11 months ago

@badmrfrosty Yes, that is when you use this command. If you type in "inspect" it should get into a loop (You can abort with pressing q). Which OS do you have?

badmrfrosty commented 11 months ago

Yeah, more or less same behaviour but I had to kill the lem process (see pictures)

uname -r 6.6.7-arch1-1

CL-USER> (sdl2-ttf:linked-version) 2 20 2

pic-selected-231219-2040-58 pic-selected-231219-2042-22

rpx99 commented 5 months ago

Found out how to work around it on OpenBSD.

Followed this instructions on Reddit in order to recompile Xenocara.

Additionally I recompiled the SDL2-TTF port with added CONFIGURE_ARGS += --disable-freetype-builtin parameter in the Makefile.

Quite time consuming build process but at least a success...

* (SDL2-TTF:RENDER-UTF8-BLENDED (sdl2-ttf:open-font #P"/home/rpx/common-lisp/lem/frontends/sdl2/resources/fonts/NotoColorEmoji.ttf" 15) (make-string 1 :initial-element #\LOCK) 255 255 255 0)
#<SDL2-FFI:SDL-SURFACE {#XB3CB9A21960}>