jsk-ros-pkg / euslime

Emacs SLIME for Euslisp
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Concurrency problem in file-load and tags command #10

Open YUKINA-3252 opened 2 years ago

YUKINA-3252 commented 2 years ago

Describe the bug

[DEBUG - bridge:L226] Socket Response: (:emacs-rex (swank:load-file "paper-folding-right.l") "USER" :repl-thread 5)

[DEBUG - server:L94] raw data: 00004d (:emacs-rex (swank:load-file "paper-folding-right.l") "USER" :repl-thread 5)

[DEBUG - protocol:L69] Processing id: 5 ...
[INFO - protocol:L71] func: swank_load_file
[INFO - protocol:L72] args: [u'paper-folding-right.l']
[DEBUG - handler:L548] Acquiring lock: <thread.lock object at 0x7fed87d5c590>
[DEBUG - server:L40] response: [Symbol(':write-string'), u'Loading file: paper-folding-right.l ...\n']
[INFO - bridge:L358] eval: (slime::load-file-and-tags "paper-folding-right.l")
[DEBUG - bridge:L226] Socket Response: 000057
[DEBUG - bridge:L226] Socket Response: (:emacs-rex (swank:find-tag-name-for-emacs "reset-pose" "USER") "USER" :repl-thread 6)

[DEBUG - server:L94] raw data: 000057 (:emacs-rex (swank:find-tag-name-for-emacs "reset-pose" "USER") "USER" :repl-thread 6)

[DEBUG - protocol:L69] Processing id: 6 ...
[INFO - protocol:L71] func: swank_find_tag_name_for_emacs
[INFO - protocol:L72] args: [u'reset-pose', u'USER']
[INFO - bridge:L332] exec_internal: (slime::find-tag-name-for-emacs "reset-pose" "USER")
[DEBUG - bridge:L334] Acquiring lock: <thread.lock object at 0x7fed87d5c5b0>
[DEBUG - bridge:L226] Socket Response: #i(48 
[ERROR - protocol:L89] Traceback (most recent call last):
  File "/home/baxter/ros/melodic/src/euslime/src/euslime/protocol.py", line 81, in process
    for resp in gen:
  File "/home/baxter/ros/melodic/src/euslime/src/euslime/handler.py", line 607, in swank_find_tag_name_for_emacs
    yield EuslispResult(self.euslisp.exec_internal(cmd))
  File "/home/baxter/ros/melodic/src/euslime/src/euslime/bridge.py", line 340, in exec_internal
    res = gen_to_string(gen)
  File "/home/baxter/ros/melodic/src/euslime/src/euslime/bridge.py", line 36, in gen_to_string
    return ''.join([x for x in list(gen) if isinstance(x, str)])
  File "/home/baxter/ros/melodic/src/euslime/src/euslime/bridge.py", line 287, in get_socket_result
    gen = self.get_socket_response(connection)
  File "/home/baxter/ros/melodic/src/euslime/src/euslime/bridge.py", line 255, in get_socket_response
    command, data = self.recv_socket_data(connection)
  File "/home/baxter/ros/melodic/src/euslime/src/euslime/bridge.py", line 246, in recv_socket_data
    command = self.recv_socket_next(connection, wait=wait)
  File "/home/baxter/ros/melodic/src/euslime/src/euslime/bridge.py", line 236, in recv_socket_next
    hex_len = int(head_data, 16)
ValueError: invalid literal for int() with base 16: '#i(48 '
YUKINA-3252 commented 2 years ago
(:emacs-rex
 (swank:load-file "paper-folding-right.l")
 "USER" :repl-thread 5)
(:write-string "Loading file: paper-folding-right.l ...\n")
(:emacs-rex
 (swank:find-tag-name-for-emacs "reset-pose" "USER")
 "USER" :repl-thread 6)
(:debug 0 1
        ("ValueError: invalid literal for int() with base 16: '#i(48 '" "" nil)
        (("QUIT" "Quit to the SLIME top level")
         ("CONTINUE" "Ignore the error and continue in the same stack level")
         ("RESTART" "Restart euslisp process"))
        nil
        (nil))
Affonso-Gui commented 2 years ago

For now I am taking a safe approach to this and blocking all (both repl and internal) operations while loading files. 18356642a3bc95bde7ac87149336c74131cd6ca4

This means that tag jumps, completion functions, documentation reference, and other requests will be postponed while loading files.

This should solve the error, but is obviously not the best solution unless we are sure that the eus subprocess is unable to reliably handle concurrent operations while loading. Therefore I am leaving this open for eventually revisiting it.