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

Elvish crashes in Emacs terminal mode #40

Closed
glycerine opened this issue Dec 18, 2014 · 6 comments
Closed

Elvish crashes in Emacs terminal mode #40

glycerine opened this issue Dec 18, 2014 · 6 comments

Comments

@glycerine
Copy link

linux/amd64/ubuntu12.04
version:
"commit 0c77f30
Author: Cheer Xiao xiaqqaix@gmail.com
Date: Tue Dec 9 14:40:04 2014 +0100

Pipes are no longer statically typed.

"

jaten@c03:$ go get -u -t -v github.com/elves/elvish
github.com/elves/elvish (download)
jaten@c03:~$ elvish
panic: runtime error: invalid memory address or nil pointer dereference
    panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4592ec]

goroutine 16 [running]:
runtime.panic(0x5302e0, 0x80d6b3)
    /home/jaten/pkg/go1.3.1/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/elves/elvish/edit.(*writer).commitBuffer(0xc208000320, 0x0, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/writer.go:216 +0x6c
github.com/elves/elvish/edit.(*writer).refresh(0xc208000320, 0xc20808a040, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/writer.go:538 +0x1cd4
github.com/elves/elvish/edit.(*Editor).refresh(0xc20808a000, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/editor.go:121 +0x21b
github.com/elves/elvish/edit.(*Editor).finishReadLine(0xc20808a000, 0xc2080247e0)
...
@xiaq
Copy link
Member

xiaq commented Dec 19, 2014

This is weird. I will try to reproduce this on Ubuntu 12.04.

@xiaq
Copy link
Member

xiaq commented Jan 21, 2015

I tried building elvish on Ubuntu 12.04 with go 1.4.1 and could not reproduce the issue. Could you try again with the latest commit? If there is still a problem, please provide me the version of the go toolchain as well as the terminal you are using; it looks like a terminal-related problem.

@glycerine
Copy link
Author

still there, crashing at writer.go:216

go1.3.3
ubuntu12.04/amd64
terminal: I run (gnu) screen, then inside screen I run "emacs -nw", then I start a shell with "M-x shell"
It does seem to be related to running inside emacs. If I start elvish just inside screen, it starts up without problem.

:~$ elvish
panic: runtime error: invalid memory address or nil pointer dereference
    panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4d4b5c]

goroutine 16 [running]:
runtime.panic(0x5cb700, 0x8cd613)
    /home/jaten/pkg/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/elves/elvish/edit.(*writer).commitBuffer(0xc2080003e0, 0x0, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/writer.go:216 +0x6c
github.com/elves/elvish/edit.(*writer).refresh(0xc2080003e0, 0xc208096040, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/writer.go:538 +0x1cd4
github.com/elves/elvish/edit.(*Editor).refresh(0xc208096000, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/editor.go:121 +0x21b
github.com/elves/elvish/edit.(*Editor).finishReadLine(0xc208096000, 0xc2080247b0)
    /home/jaten/go/src/github.com/elves/elvish/edit/editor.go:298 +0x1bd
runtime.panic(0x5cb700, 0x8cd613)
    /home/jaten/pkg/go/src/pkg/runtime/panic.c:248 +0x18d
github.com/elves/elvish/edit.(*writer).commitBuffer(0xc2080003e0, 0x0, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/writer.go:216 +0x6c
github.com/elves/elvish/edit.(*writer).refresh(0xc2080003e0, 0xc208096040, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/writer.go:538 +0x1cd4
github.com/elves/elvish/edit.(*Editor).refresh(0xc208096000, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/editor.go:121 +0x21b
github.com/elves/elvish/edit.(*Editor).ReadLine(0xc208096000, 0x631250, 0x7f5207c97e10, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/jaten/go/src/github.com/elves/elvish/edit/editor.go:328 +0x1e1
main.interact()
    /home/jaten/go/src/github.com/elves/elvish/main.go:66 +0x389
main.main()
    /home/jaten/go/src/github.com/elves/elvish/main.go:133 +0x2c

@xiaq
Copy link
Member

xiaq commented Jan 21, 2015

Thanks. Now I can reproduce that. I'll look into it some time.

The editor part of Elvish makes quite some assumptions about the terminal so it's no surprise that it panics when run in an exotic terminal. It should be programmed more defensively though.

xiaq added a commit that referenced this issue Jan 21, 2015
@xiaq xiaq changed the title ug. elvish crashes immediately, right out of the box Elvish crashes in Emacs shell mode Jan 21, 2015
@xiaq xiaq changed the title Elvish crashes in Emacs shell mode Elvish crashes in Emacs terminal mode Jan 21, 2015
@xiaq
Copy link
Member

xiaq commented Jan 21, 2015

The Emacs pseudo-tty has really limited capability. For one thing, it does not implement the TIOCGWINSZ ioctl call properly, which is used is query the window size. Instead of the actual window size it always indicates a width of 0 and a height of 0.

I fixed the code so that it will now no longer panic. But Elvish still will not function properly (e.g. you will see some garbage characters) since the line editor relies on the availability of the more advanced terminal capabilities. Actually the line editor of Elvish in its currently form is essentially a full-screen application comparable to Vim.

I might add some "fallback mode" to the line editor at some time in future.

@xiaq
Copy link
Member

xiaq commented Jan 21, 2015

For further discussion, see #41.

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

No branches or pull requests

2 participants