Skip to content

color.SetOutput() panics on go 1.17 #46

@shoenseiwaso

Description

@shoenseiwaso

The problem is on this line:

if w, ok := w.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {

The panic is fixed v0.0.14 of the upstream go-isatty, via mattn/go-isatty#66

Root cause is here:
golang/go#47776

Here's what the panic looks like on go 1.17:

runtime.sigpanic()
	/usr/local/Cellar/go/1.17/libexec/src/runtime/signal_unix.go:719 +0x396

goroutine 1 [syscall, locked to thread]:
syscall.syscall(0x4321040, 0x1, 0x40487413, 0xc00015b8c0)
	/usr/local/Cellar/go/1.17/libexec/src/runtime/sys_darwin.go:22 +0x3b fp=0xc00015b830 sp=0xc00015b810 pc=0x4061bfb
syscall.syscall(0xc00010cea0, 0xc00015b900, 0x400ee34, 0x100000000000000)
	<autogenerated>:1 +0x26 fp=0xc00015b878 sp=0xc00015b830 pc=0x4067926
golang.org/x/sys/unix.ioctl(0x18, 0x100000004a9d108, 0x4aa6328)
	/Users/jeff/go/pkg/mod/golang.org/x/sys@v0.0.0-20200930185726-fdedc70b468f/unix/zsyscall_darwin_amd64.go:731 +0x39 fp=0xc00015b8a8 sp=0xc00015b878 pc=0x4320cd9
golang.org/x/sys/unix.IoctlGetTermios(...)
	/Users/jeff/go/pkg/mod/golang.org/x/sys@v0.0.0-20200930185726-fdedc70b468f/unix/ioctl.go:72
github.com/mattn/go-isatty.IsTerminal(0x44ff480)
	/Users/jeff/go/pkg/mod/github.com/mattn/go-isatty@v0.0.12/isatty_bsd.go:10 +0x50 fp=0xc00015b918 sp=0xc00015b8a8 pc=0x433f470
github.com/labstack/gommon/color.(*Color).SetOutput(0xc00000e3f0, {0x4609b40, 0xc000010018})
	/Users/jeff/go/pkg/mod/github.com/labstack/gommon@v0.3.0/color/color.go:146 +0x92 fp=0xc00015b938 sp=0xc00015b918 pc=0x433f8b2
github.com/labstack/gommon/color.New(...)
	/Users/jeff/go/pkg/mod/github.com/labstack/gommon@v0.3.0/color/color.go:134
github.com/labstack/gommon/color.init()
	/Users/jeff/go/pkg/mod/github.com/labstack/gommon@v0.3.0/color/color.go:102 +0x4ea fp=0xc00015b968 sp=0xc00015b938 pc=0x4340f6a
runtime.doInit(0x48edce0)
	/usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:6498 +0x123 fp=0xc00015baa0 sp=0xc00015b968 pc=0x4044c03
runtime.doInit(0x48f2320)
	/usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:6475 +0x71 fp=0xc00015bbd8 sp=0xc00015baa0 pc=0x4044b51
runtime.doInit(0x48f10c0)
	/usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:6475 +0x71 fp=0xc00015bd10 sp=0xc00015bbd8 pc=0x4044b51
runtime.doInit(0x48f11a0)
	/usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:6475 +0x71 fp=0xc00015be48 sp=0xc00015bd10 pc=0x4044b51
runtime.doInit(0x48efba0)
	/usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:6475 +0x71 fp=0xc00015bf80 sp=0xc00015be48 pc=0x4044b51
runtime.main()
	/usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:238 +0x1e6 fp=0xc00015bfe0 sp=0xc00015bf80 pc=0x4037ce6
runtime.goexit()
	/usr/local/Cellar/go/1.17/libexec/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00015bfe8 sp=0xc00015bfe0 pc=0x40652a1
exit status 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions