joaotavora / sly

Sylvester the Cat's Common Lisp IDE
1.26k stars 142 forks source link

M-x sly-disconnect crashes SBCL if connected via ssh tunnel #508

Open nathanvy opened 2 years ago

nathanvy commented 2 years ago

Hi. Thanks for all your work on sly, I really enjoy using it. This is a strange issue so I'll just jump right into it. To reproduce:

  1. Install sbcl on Debian 11 Stable
  2. $ sbcl
  3. Invoke the slynk server:
    * (ql:quickload :slynk)
    To load "slynk":
    Load 1 ASDF system:
    asdf
    Install 1 Quicklisp release:
    sly
    ; Fetching #<URL "http://beta.quicklisp.org/archive/sly/2022-02-20/sly-20220220-git.tgz">
    ; 1792.02KB
    ==================================================
    1,835,032 bytes in 0.32 seconds (5549.49KB/sec)
    ; Loading "slynk"
    [package slynk-backend]...........................
    [package slynk-mop]...............................
    [package slynk-source-path-parser]................
    [package slynk-source-file-cache].................
    [package slynk-sbcl]..............................
    [package slynk-gray]..............................
    [package slynk-match].............................
    [package slynk-rpc]...............................
    [package slynk]...................................
    ..................................................
    [package slynk-api]...............................
    [package slynk-completion]........................
    [package slynk-completion-local-nicknames-test]...
    [package slynk-apropos].
    SLYNK's ASDF loader finished.(:SLYNK)
    * (slynk:create-server :dont-close t)
    ;; Slynk started at port: 4005.
    4005
    *
  4. Establish an ssh tunnel to the server: $ ssh -N -L 4005:127.0.0.1:4005 ssh.example.com
  5. Launch emacs and sly on local machine and immediately connect to the remote repl: M-x sly-connect RET RET
  6. Immediately disconnect: M-x sly-disconnect

Expected result: REPL keeps running on remote machine

Actual result: SBCL on the remote machine crashes, with 300+ lines of nested errors in the stack trace. For legibility reasons I put it into a gist: https://gist.github.com/nathanvy/6a06f5362e9855b1cbf57b7a0d15a0f2

I have no clue how to proceed from here but it seems like sly-disconnect is causing the slynk server to choke when it tries to close a channel that's already closed.