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

lisps instantiated by M-x slime get killed when reading from unexpectedly unplugged USB serial devices #333

Open
ghost opened this Issue Aug 23, 2016 · 5 comments

Comments

Projects
None yet
1 participant
@ghost

ghost commented Aug 23, 2016

So in order to reproduce this bug on my linux 64 bit laptop or desktop arch linux setup (emacs 24.5.1 on the desktop):

  • plug in a usb serial device to a linux machine
  • fire up ccl lisp using M-x slime
  • run this code at the repl (with-open-file (foo "/dev/ttyUSB0") (read-line foo))
  • while it's waiting for input, pull out the usb cable for the device

On my machine something kills the inferior-lisp. I'm guessing slime catches sighup and does the deed.

If I manually fire up a lisp, run swank, then M-x slime-connect it drops me into the slime debugger as expected with "Unexpected end of file" - so at least I have a workaround for now!

@ghost ghost changed the title from lisps instantiated by M-x slime get killed when reading from unplugged USB serial devices to lisps instantiated by M-x slime get killed when reading from unexpectedly unplugged USB serial devices Aug 23, 2016

@luismbo

This comment has been minimized.

Show comment
Hide comment
@luismbo

luismbo Aug 24, 2016

Member

Interesting bug. Can we reproduce this without a USB device being involved? E.g., does sending a sighup to the Lisp process using kill have the same effect?

Member

luismbo commented Aug 24, 2016

Interesting bug. Can we reproduce this without a USB device being involved? E.g., does sending a sighup to the Lisp process using kill have the same effect?

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 24, 2016

Can't reproduce exactly the same behaviour using "kill -s HUP".

The symptoms are the same as yanking a usb cable for the lisp started with M-x slime - i.e lisp dies without dropping into debugger with the message "Process inferior-lisp hangup".

However with a lisp started manually "kill -s HUP" still kills the process, rather than dropping into the debugger. Dunno if that's expected or not!?

ghost commented Aug 24, 2016

Can't reproduce exactly the same behaviour using "kill -s HUP".

The symptoms are the same as yanking a usb cable for the lisp started with M-x slime - i.e lisp dies without dropping into debugger with the message "Process inferior-lisp hangup".

However with a lisp started manually "kill -s HUP" still kills the process, rather than dropping into the debugger. Dunno if that's expected or not!?

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 24, 2016

Discovered another workaround, using the trivial-signal package:

(trivial-signal:signal-handler-bind
     ((#.trivial-signal:+sighup+ (lambda (x)
                                     (print 'zoinks))))
 (with-open-file (foo "/dev/ttyUSB0"
                        :direction :input
                        :if-exists :overwrite
                        :element-type '(unsigned-byte 8))
         (loop (print (read-byte foo)))))

Either sending sighup via kill, or yanking the usb cable triggers the signal-handler for sighup, but game-over now prevented, even for a lisp started with M-x slime. Yanking the usb cable raises an additional condition "Unexpected end of file", as expected...

ghost commented Aug 24, 2016

Discovered another workaround, using the trivial-signal package:

(trivial-signal:signal-handler-bind
     ((#.trivial-signal:+sighup+ (lambda (x)
                                     (print 'zoinks))))
 (with-open-file (foo "/dev/ttyUSB0"
                        :direction :input
                        :if-exists :overwrite
                        :element-type '(unsigned-byte 8))
         (loop (print (read-byte foo)))))

Either sending sighup via kill, or yanking the usb cable triggers the signal-handler for sighup, but game-over now prevented, even for a lisp started with M-x slime. Yanking the usb cable raises an additional condition "Unexpected end of file", as expected...

@luismbo

This comment has been minimized.

Show comment
Hide comment
@luismbo

luismbo Aug 24, 2016

Member

What happens when you do these same things with SBCL instead of CCL?

Member

luismbo commented Aug 24, 2016

What happens when you do these same things with SBCL instead of CCL?

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 24, 2016

I see exactly the same behaviour with sbcl instead of CCL for 6 test cases. Summarised version of the results:

  • manually start swank & slime-connect, send sighup with kill (no trivial-signal handler) lisp process killed
  • manually start swank & slime-connect, yank usb cable (no trivial-signal handler) lisp process survives, thrown into sldb with "Unexpected end of file"
  • M-x slime, send sighup with kill (no trivial-signal-handler) lisp process killed
  • M-x slime, yank usb cable (no trivial-signal-handler) lisp process killed
  • M-x slime, send sighup with kill (wrapping blocking read in a trivial-signal-handler) lisp process survives, thrown into sldb with "received HUP"
  • M-x slime, yank usb cable (wrapping blocking read in a trivial-signal-handler) lisp process survives, thrown into sldb with "received HUP", invoke restart 0 IGNORE, thrown into sldb with "Unexpected end of file"

ghost commented Aug 24, 2016

I see exactly the same behaviour with sbcl instead of CCL for 6 test cases. Summarised version of the results:

  • manually start swank & slime-connect, send sighup with kill (no trivial-signal handler) lisp process killed
  • manually start swank & slime-connect, yank usb cable (no trivial-signal handler) lisp process survives, thrown into sldb with "Unexpected end of file"
  • M-x slime, send sighup with kill (no trivial-signal-handler) lisp process killed
  • M-x slime, yank usb cable (no trivial-signal-handler) lisp process killed
  • M-x slime, send sighup with kill (wrapping blocking read in a trivial-signal-handler) lisp process survives, thrown into sldb with "received HUP"
  • M-x slime, yank usb cable (wrapping blocking read in a trivial-signal-handler) lisp process survives, thrown into sldb with "received HUP", invoke restart 0 IGNORE, thrown into sldb with "Unexpected end of file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment