[Openmcl-devel] Raw-mode terminal weirdness redux
Ron Garret
ron at flownet.com
Tue Mar 27 09:32:54 PDT 2018
Found a reliable workaround!
(defun %write (s)
(with-cstrs ((cs s))
(#_write 1 cs (length s))))
(defun test ()
(rlet ((normal :termios))
(#_tcgetattr 0 normal) ; This breaks it
(rlet ((raw :termios))
(#_tcgetattr 0 normal)
(#_cfmakeraw raw)
(%write "abc")
(unwind-protect
(progn
(#_tcsetattr 0 2 raw)
(%write "def"))
(#_tcsetattr 0 2 normal)))
(%write "hij")))
This version is broken. If you comment out the line that says “This breaks it” it will start working properly. Both working and non-working versions are 100% reliable. Using a single RLET to allocate both termios structures also works. It’s only when there is a call to tcgetattr in between the allocations that it breaks. (Note that the “broken” version works in 1.8. But for the fact that C code can reproduce this problem intermittently I would call this slam-dunk evidence that this is a bug in the CCL compiler, most likely in RLET. But since the C code does what it does, I’m not willing to go quite that far.)
I’m not sure if this qualifies me to claim my own bug bounty or not :-)
Note that we now have this extremely interesting situation where a Lisp program is more reliable than the corresponding C program!
rg
More information about the Openmcl-devel
mailing list