Skip to content
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

Panic while debugging using VSCODE linux #71

Open
simulot opened this issue Jun 3, 2018 · 4 comments
Open

Panic while debugging using VSCODE linux #71

simulot opened this issue Jun 3, 2018 · 4 comments
Labels

Comments

@simulot
Copy link

simulot commented Jun 3, 2018

Bug reports

When placing a breakpoint is my code, the program is panicking

Expected Behavior

Debugging go-prompt application should not make the program panicking

Current Behavior and Steps to Reproduce

Place a break point into some of provided examples, let say in completer function
When the breakpoint is reached, the debug console shows:

API server listening at: 127.0.0.1:24621
]2;sql-prompt�
panic: inappropriate ioctl for device
goroutine 1 [running]:
github.com/c-bata/go-prompt.(*PosixParser).GetWinSize(0xc4200220a0, 0x0)
	/home/simulot/go/src/github.com/c-bata/go-prompt/posix_input.go:113 +0x16e
github.com/c-bata/go-prompt.(*Prompt).setUp(0xc42008a060)
	/home/simulot/go/src/github.com/c-bata/go-prompt/prompt.go:264 +0x69
github.com/c-bata/go-prompt.(*Prompt).Run(0xc42008a060)
	/home/simulot/go/src/github.com/c-bata/go-prompt/prompt.go:49 +0x9e
main.main()
	/home/simulot/go/src/github.com/c-bata/go-prompt/_example/echo/main.go:30 +0x120
...

Context

  • Operating System:
    ubuntu mint 18.3
    go version go1.10.1 linux/amd64

  • Terminal Emulator: (i.e. iTerm2)
    vscode 1.23.1 integrated terminal

  • tag of go-prompt or commit revision:
    I have used go get command.

@c-bata c-bata added the bug label Jun 3, 2018
@c-bata
Copy link
Owner

c-bata commented Jun 3, 2018

(this is just a memo for me)

A current commit revision is 2f3ee57 . This panic is raised at

go-prompt/posix_input.go

Lines 106 to 114 in 2f3ee57

retCode, _, errno := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(t.fd),
uintptr(syscall.TIOCGWINSZ),
uintptr(unsafe.Pointer(ws)))
if int(retCode) == -1 {
panic(errno)
}

And maybe retCode was 25

@simulot
Copy link
Author

simulot commented Jun 3, 2018

Let me know if I can help.

@c-bata
Copy link
Owner

c-bata commented Jun 3, 2018

I don't know why this panic is raised but ptrace system call that is used by GDB for tracing processes may disturb ioctl execution.

I found a similar issue, but this issue is not resolved.
quarnster/SublimeGDB#38

@simulot
Copy link
Author

simulot commented Jul 12, 2018

In fact, the problem is not in your code, but somewhere in between vs-code and dlv.
It seems that stdin is not available in the debuging context. Someone has suggested to use dlv headless feature... and this works.

First, add a launch configuration for remote in launch.json

        {
            "name": "Remote",
            "type": "go",
            "request": "launch",
            "mode": "remote",
            "remotePath": "${workspaceRoot}",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}",
            "env": {}
        }

In the terminal windows, in the package folder, launch dlv:
dlv debug --headless --listen=:2345

Then launch the debug session using the remote configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants