sb-posix:tcsetattr segfaults on OpenBSD

Bug #1999092 reported by David Lamkins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

$ sbcl --version
SBCL 2.2.5.openbsd
$ uname -a
OpenBSD gilva.local 7.2 GENERIC.MP#2 amd64

Test case

(require 'sb-posix)

(defun invoke-with-echoing-disabled (thunk)
  (let ((fd (sb-sys:fd-stream-fd sb-sys:*stdout*)))
    (if (zerop (sb-unix:unix-isatty fd))
      (funcall thunk)
      (let ((termios (sb-posix:tcgetattr fd)))
        (setf (sb-posix:termios-lflag termios)
              (logand (sb-posix:termios-lflag termios)
                      (lognot sb-posix:echo)))
        (sb-posix:tcsetattr fd sb-posix:tcsaflush termios)
        (unwind-protect
          (funcall thunk)
          (setf (sb-posix:termios-lflag termios)
                (logior (sb-posix:termios-lflag termios)
                        sb-posix:echo))
          (sb-posix:tcsetattr fd sb-posix:tcsaflush termios))))))

(defmacro with-echoing-disabled (&body body)
  `(invoke-with-echoing-disabled (lambda () ,@body)))

$ sbcl --load test.lisp --eval '(with-echoing-disabled (read))'

Expected behavior: I type a form which is not echoed, but is printed when I press enter.
Observed behavior: sbcl exits immediately.

When I ktrace the above invocation, I can see the tcgetattr call succeed, but there's a SEGV where the tcsetattr trace should appear.

Note that the same code works as intended running on the sbcl packaged for Ubuntu:

$ sbcl --version
SBCL 2.1.11.debian
$ uname -a
Linux dlamkins-0316 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.