lem-project / lem

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

An error occurs when typing any keys in Ubuntu 22.04 #638

Closed t-sin closed 4 months ago

t-sin commented 1 year ago

I found an error occurs when typing any keys, after launching lem.

Environment

$ uname -a
Linux dhole 5.15.0-72-generic #79~20.04.1-Ubuntu SMP Thu Apr 20 22:12:07 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"

Detailed behavior

After launching lem, I typed some keys to input texts then the GUI window disappears and these stack trace below is shown:

Unhandled TYPE-ERROR in thread #<SB-THREAD:THREAD "SDL2 Main Thread" RUNNING
                                  {100A3F0113}>:
  The value
    115
  is not of type
    VECTOR
  when binding #:LOOP-ACROSS-VECTOR-15

Backtrace for: #<SB-THREAD:THREAD "SDL2 Main Thread" RUNNING {100A3F0113}>
0: ((:METHOD LEM-SDL2/KEYBOARD:HANDLE-TEXT-INPUT (LEM-SDL2/PLATFORM:LINUX T)) #<unused argument> 115) [fast-method]
1: ((LAMBDA NIL :IN LEM-SDL2::EVENT-LOOP))
2: ((LAMBDA NIL :IN LEM-SDL2::CREATE-DISPLAY))
3: (SDL2::HANDLE-MESSAGE (#<FUNCTION (LAMBDA NIL :IN LEM-SDL2::CREATE-DISPLAY) {1008AA82DB}> . #S(TRIVIAL-CHANNELS:CHANNEL :QUEUE #S(TRIVIAL-CHANNELS.QUEUE:QUEUE :HEAD NIL :TAIL NIL) :Q-CONDITION #<SB-THREAD:WAITQUEUE Anonymous condition variable {1008AA8313}> :Q-MUTEX #<SB-THREAD:MUTEX "Anonymous lock" free owner=0>)))
4: (SDL2::SDL-MAIN-THREAD)
5: ((LAMBDA NIL :IN BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS))
6: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
7: ((FLET "WITHOUT-INTERRUPTS-BODY-156" :IN SB-THREAD::RUN))
8: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
9: ((FLET "WITHOUT-INTERRUPTS-BODY-149" :IN SB-THREAD::RUN))
10: (SB-THREAD::RUN)
11: ("foreign function: call_into_lisp_")
12: ("foreign function: funcall1")

unhandled condition in --disable-debugger mode, quitting

It seems that it caused by external input values from out of lem codes, like SDL2 or something.

Workaround

I found this workaround:

diff --git a/frontends/sdl2/keyboard.lisp b/frontends/sdl2/keyboard.lisp
index c8b4b1fc..09b30c11 100644
--- a/frontends/sdl2/keyboard.lisp
+++ b/frontends/sdl2/keyboard.lisp
@@ -130,7 +130,9 @@
 (defmethod handle-text-input ((platform lem-sdl2/platform:linux) text)
   (log:info *modifier*)
   (when (modifier-is-accept-text-input-p *modifier*)
-    (loop :for c :across text
+    (loop :for c :across (if (typep text 'number)
+                             (format nil "~a" (code-char text))
+                             text)
           :do (multiple-value-bind (sym text-input-p) (convert-to-sym (char-code c))
                 (let ((key (lem:make-key :ctrl (modifier-ctrl *modifier*)
                                          :meta (modifier-meta *modifier*)

I'll continue to debug it.

cxxxr commented 1 year ago

Thank you for your report. Are there incompatible changes around ffi?

I'll commit the workaround to the master branch.

Sasanidas commented 1 year ago

Did the workaround worked? (ping @t-sin )

Thanks!

t-sin commented 1 year ago

I'm sorry for delay. That workaround works in the latest master branch!

I'll continue to debug it.

But I don't do this yet, sorry...

cxxxr commented 4 months ago

Close this issue. If there are still problems, someone will shout.