mattn / jvgrep

grep for japanese vimmer
https://mattn.kaoriya.net/
140 stars 19 forks source link

crash on Linux #60

Closed koron closed 7 years ago

koron commented 7 years ago

Xubuntu 17.04 + go1.9 (official binary) で HEAD の jvgrep をビルドして実行した結果、以下のように crash しています。詳細は不明。 Windows では再現できていません。

koron@miya ~/gowork/src/github.com/mattn/jvgrep
$ go version
go version go1.9 linux/amd64

koron@miya ~/gowork/src/github.com/mattn/jvgrep
$ jvgrep --version
5.2

koron@miya ~/gowork/src/github.com/mattn/jvgrep
$ jvgrep -r TODO .
panic: runtime error: slice bounds out of range

goroutine 21 [running]:
internal/poll.(*FD).Write(0xc420084050, 0xc420163c00, 0x3b, 0x9, 0x0, 0x0, 0x0)
    /home/koron/opt/golang/src/internal/poll/fd_unix.go:218 +0x380
os.(*File).write(0xc420082008, 0xc420163c00, 0x3b, 0x9, 0x3b, 0xc420163c00, 0x3b)
    /home/koron/opt/golang/src/os/file_unix.go:233 +0x4e
os.(*File).Write(0xc420082008, 0xc420163c00, 0x3b, 0x9, 0x7, 0x7, 0x8)
    /home/koron/opt/golang/src/os/file.go:140 +0x72
main.printBytesNorm(0xc420163c00, 0x3b, 0x9)
    /home/koron/gowork/src/github.com/mattn/jvgrep/jvgrep.go:116 +0x53
main.printStr(0xc420163c00, 0x3b)
    /home/koron/gowork/src/github.com/mattn/jvgrep/jvgrep.go:104 +0x46
main.matchedLine(0xc42018a20f, 0x14, 0x2b, 0xc420163bc0, 0x3b, 0xc4201ba0f0)
    /home/koron/gowork/src/github.com/mattn/jvgrep/jvgrep.go:161 +0x830
main.doGrep(0xc42018a1e0, 0x43, 0xc4201ec000, 0x1388, 0x1588, 0xc4201ba0f0, 0x0)
    /home/koron/gowork/src/github.com/mattn/jvgrep/jvgrep.go:434 +0xd03
main.Grep(0xc4201ba0f0, 0xc420042f00)
    /home/koron/gowork/src/github.com/mattn/jvgrep/jvgrep.go:525 +0x517
main.goGrep(0xc4200f61e0, 0xc420100120)
    /home/koron/gowork/src/github.com/mattn/jvgrep/jvgrep.go:535 +0x5c
created by main.doMain
    /home/koron/gowork/src/github.com/mattn/jvgrep/jvgrep.go:876 +0x43c
koron commented 7 years ago

printStr() で unsafe を使うのをやめたら落ちなくなった。

func printStr(s string) {
    printBytes([]byte(s))
}
mattn commented 7 years ago

なおしまーす

koron commented 7 years ago

これ、goのほうでレイアウト変わって、単なるキャストじゃ済まなくなったってことですか?

mattn commented 7 years ago

んー。わからんす。

mattn commented 7 years ago

@zchee さんから似たような話を聞きました。

mattn commented 7 years ago

released

koron commented 7 years ago

ありがとうございます :bowing_man:

mattn commented 7 years ago

こちらこそ

mattn commented 7 years ago

追記ed: http://qiita.com/mattn/items/176459728ff4f854b165

zchee commented 7 years ago

reflectでちゃんとヘッダとかを作れば1.9でも大丈夫だったはずです

koron commented 7 years ago

少しだけ追ったのでその報告です。不要かもですが。1.9 から unix に poll.Fd という型が増えて、その Write() の中で p[0:len(p)] 相当をやってるところがあって、そこで落ちてました。

mattn commented 7 years ago

jvgrep の出す文字列は細かい文字列の方が多く reflect でヘッダ付けたりすると逆に速度劣化につながりそうなのでひとまず []byte キャストにしました。ありがとうございます。

zchee commented 7 years ago

:bow: