-
Notifications
You must be signed in to change notification settings - Fork 18k
syscall: CL 178919 breaks use of github.com/kr/pty #32527
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
Comments
Forgot to cc @kr |
When you call I don't quite see how github.com/kr/pty works today. It uses It might help to compare an It might fix the problem if github.com/kr/pty were changed to use Edit: this analysis was flawed because I was not looking at the same version of the pty package that @myitcv was using. |
CC @gthelen |
I'm happy to help with changes to github.com/kr/pty if necessary, especially if there are steps we can follow to reproduce this. Also cc @creack. |
Happy to help, however, I cloned and installed 103b5b6 on linux/amd64 (ubuntu 16.04) and have not been able to reproduce. I tried vim, bash, emacs, tmux using the sample code form kr/pty readme without a problem. Could you provide a more detailed way to reproduce? Using syscall.Open instead of os.OpenFile could be done as well. For reference, here is what I tested with, from https://github.com/kr/pty/blob/master/README.md#shell package main
import (
"io"
"log"
"os"
"os/exec"
"os/signal"
"syscall"
"github.com/kr/pty"
"golang.org/x/crypto/ssh/terminal"
)
func test() error {
// Create arbitrary command.
c := exec.Command("vim")
// Tried this and variations.
c.SysProcAttr = &syscall.SysProcAttr{
Setsid: true,
Setctty: true,
}
// Start the command with a pty.
ptmx, err := pty.Start(c)
if err != nil {
return err
}
// Make sure to close the pty at the end.
defer func() { _ = ptmx.Close() }() // Best effort.
// Handle pty size.
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGWINCH)
go func() {
for range ch {
if err := pty.InheritSize(os.Stdin, ptmx); err != nil {
log.Printf("error resizing pty: %s", err)
}
}
}()
ch <- syscall.SIGWINCH // Initial resize.
// Set stdin in raw mode.
oldState, err := terminal.MakeRaw(int(os.Stdin.Fd()))
if err != nil {
panic(err)
}
defer func() { _ = terminal.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort.
// Copy stdin to the pty and the pty to stdout.
go func() { _, _ = io.Copy(ptmx, os.Stdin) }()
_, _ = io.Copy(os.Stdout, ptmx)
return nil
}
func main() {
if err := test(); err != nil {
log.Fatal(err)
}
} |
I'm also happy to help, but have no problems running creack's vim workload (#32527 (comment)) with golang 103b5b6 on linux/amd64. |
Thanks very much for all the offers of help debugging this. I've not actually managed to create a repro that shows exactly the same symptoms, but I do have a small example that fails pre/post that CL in a slightly different but perhaps related way. That follows at the end of this comment. In what follows I will use:
I've also tried to keep this issue a bit shorter by putting details in separate repo. Vim version details for all my tests, attempted repros etc: Original issuePer @ianlancetaylor I've used
In answer to your specific question, @ianlancetaylor :
No; simply setting a working directory and environment. Please excuse the code in Small exampleThe simple example in https://github.com/myitcvscratch/ptyrepro also breaks as a result of CL 178919, but not in the same way. Pre:
No output; i.e. no panic. Post:
Here is the Again, happy to help provide any further details that help to track this down. |
Thanks for the strace listings and the small repro. When I If I change the go.mod file in your small repro to
then your program succeeds. |
@ianlancetaylor - thank you for taking the time to look into this, very much appreciated. I can confirm that with kr/pty@b6e1bdd both my repro and the original issue are resolved. I will close this issue and open an issue in https://github.com/kr/pty about cutting a new release. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
CL 178919 has broken my test setup with
govim
.I'm ever so slightly out of my depth when it comes to understanding what's going on, so I'll simply describe the setup and offer to provide as many further details as necessary (if someone can give me pointers as to how) 😄!
github.com/kr/pty
to start an instance of Vimpty.Start
fails with:I haven't yet managed to create a smaller reproduction outside of
govim
, rather I wanted to report the issue first given how close we are to beta1.cc @ianlancetaylor
The text was updated successfully, but these errors were encountered: