owenthereal / ccat

Colorizing `cat`
https://github.com/owenthereal/ccat
MIT License
3.16k stars 118 forks source link

go panics on some files #68

Open axelson opened 6 years ago

axelson commented 6 years ago

Seems to happen the most on long "jsonl" files. That is a file with JSON that has a new JSON document on each line.

Here's an example stack trace:

fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x23bc300fde44 pc=0x27209]

runtime stack:
runtime.throw(0x21cd00, 0x2a)
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/panic.go:527 +0x90
runtime.sigpanic()
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/sigpanic_unix.go:12 +0x5a
runtime.(*gcWork).put(0xc820022720, 0xc8204bc000)
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/mgcwork.go:87 +0x49
runtime.greyobject(0xc8204bc000, 0x0, 0x0, 0xc81ffda1ff, 0x0, 0x66fe40, 0xc820022720)
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/mgcmark.go:956 +0x2f1
runtime.shade(0xc8204bc024)
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/mgcmark.go:894 +0x9a
runtime.gcmarkwb_m(0xc8204bc000, 0xc8204bc024)
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/mbarrier.go:91 +0xc1
runtime.writebarrierptr_nostore1.func1()
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/mbarrier.go:117 +0x134
runtime.systemstack(0xc820021500)
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:262 +0x79
runtime.mstart()
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/proc1.go:674

goroutine 1 [running]:
runtime.systemstack_switch()
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:216 fp=0xc820055288 sp=0xc820055280
runtime.writebarrierptr_nostore1(0xc8204bc000, 0xc8204bc024)
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/mbarrier.go:118 +0x71 fp=0xc8200552c0 sp=0xc820055288
runtime.writebarrierptr(0xc8204bc000, 0xc8204bc024)
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/mbarrier.go:137 +0x4b fp=0xc8200552f0 sp=0xc8200552c0
bytes.(*Buffer).grow(0xc8204bc000, 0x5, 0xe160ebb)
        /usr/local/Cellar/go/1.5.1/libexec/src/bytes/buffer.go:106 +0x151 fp=0xc820055398 sp=0xc8200552f0
bytes.(*Buffer).WriteString(0xc8204bc000, 0xc82006a710, 0x5, 0x5, 0x0, 0x0)
        /usr/local/Cellar/go/1.5.1/libexec/src/bytes/buffer.go:140 +0x4b fp=0xc820055400 sp=0xc820055398
main.Colorize(0x1ddb00, 0x5, 0xc8204ba000, 0xd, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/color.go:111 +0xcc6 fp=0xc820055728 sp=0xc820055400
main.Printer.Print(0xc82006c600, 0x6641c0, 0xc82008c008, 0x1, 0xc8204ba000, 0xd, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/printer.go:140 +0x7c fp=0xc820055778 sp=0xc820055728
github.com/jingweno/ccat/Godeps/_workspace/src/github.com/sourcegraph/syntaxhighlight.Print(0xc8200a8b00, 0x6641c0, 0xc82008c008, 0x664550, 0xc82006c600, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/.gopath/src/github.com/jingweno/ccat/Godeps/_workspace/src/github.com/sourcegraph/syntaxhighlight/highlight.go:162 +0xd1 fp=0xc8200557e8 sp=0xc820055778
main.CPrint(0x664528, 0xc82008c020, 0x6641c0, 0xc82008c008, 0xc82006c600, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/printer.go:130 +0xa3 fp=0xc820055848 sp=0xc8200557e8
main.ColorPrinter.Print(0xc82006c600, 0x664528, 0xc82008c020, 0x6641c0, 0xc82008c008, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/ccat.go:34 +0x55 fp=0xc820055888 sp=0xc820055848
main.AutoColorPrinter.Print(0xc82006c600, 0x664528, 0xc82008c020, 0x6641c0, 0xc82008c008, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/ccat.go:23 +0x7a fp=0xc8200558d0 sp=0xc820055888
main.CCat(0x7ffeefbff755, 0xa, 0x664500, 0xc82006c600, 0x6641c0, 0xc82008c008, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/ccat.go:75 +0x1fc fp=0xc8200559a8 sp=0xc8200558d0
main.(*ccatCmd).Run(0xc82006c6f0, 0xc820070b60, 0xc82006aac0, 0x1, 0x1)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/main.go:81 +0x7af fp=0xc820055c48 sp=0xc8200559a8
main.(*ccatCmd).Run-fm(0xc820070b60, 0xc82006aac0, 0x1, 0x1)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/main.go:102 +0x48 fp=0xc820055c78 sp=0xc820055c48
github.com/jingweno/ccat/Godeps/_workspace/src/github.com/spf13/cobra.(*Command).execute(0xc820070b60, 0xc820090010, 0x1, 0x1, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/.gopath/src/github.com/jingweno/ccat/Godeps/_workspace/src/github.com/spf13/cobra/command.go:495 +0x6e3 fp=0xc820055d88 sp=0xc820055c78
github.com/jingweno/ccat/Godeps/_workspace/src/github.com/spf13/cobra.(*Command).Execute(0xc820070b60, 0x0, 0x0)
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/.gopath/src/github.com/jingweno/ccat/Godeps/_workspace/src/github.com/spf13/cobra/command.go:560 +0x180 fp=0xc820055e88 sp=0xc820055d88
main.main()
        /private/tmp/ccat20151130-62599-1v7ai72/ccat-1.1.0/main.go:127 +0x4f4 fp=0xc820055f50 sp=0xc820055e88
runtime.main()
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/proc.go:111 +0x2b0 fp=0xc820055fa0 sp=0xc820055f50
runtime.goexit()
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:1696 +0x1 fp=0xc820055fa8 sp=0xc820055fa0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:1696 +0x1
jackwilsdon commented 6 years ago

That's a bit scary! It looks like a segfault in Go itself. I can't reproduce this on a 5.4mb 10k line jsonl file when building under Go 1.11, so maybe it has been fixed? Have you tried reinstalling ccat with a newer version of Go?

axelson commented 6 years ago

How do I check what version ccat was compiled with? I don't see that in the output of ccat --version. Also I'm still getting this on a 4.6M jsonl file on ccat v1.1.0.

jackwilsdon commented 6 years ago

Did you download ccat from the releases page or install it yourself with go get? If you installed it with go get you can check by using go version (provided you haven't updated Go since).

axelson commented 6 years ago

I installed via homebrew