-
-
Notifications
You must be signed in to change notification settings - Fork 741
Description
Description
Hello! First of all, I would like to say thank you for your work, I have 'sold' task to my teammates in multiple companies for go projects instead of make
. This is my first issue for public OSS projet
Context: if I include pipefail in shopt
- task panics without clear error message.
this code panics for me:
set:
- pipefail
- nounset
- errexit
shopt:
- pipefail
and this one
# set: <- may be empty.
shopt:
- pipefail
It is clear here the problem is invalid pipefail
that is in shopt
, however it has to be in set
.
task: [default] echo 'I will not work'
shopt: invalid option name "abcd"
task: Failed to run task "default": exit status 1
This issue happens only with pipefail
and not with other invalid non existing options.
Issue: task panics with weird 'panic: runtime error: index out of range [-1]'.
Expected: give user more clear and friendly information of what happened. Maybe add helpful message that tells move pipefail
into set
and explanation of possible options.
Or give user this message: shopt: invalid option name "pipefail"
Something bad happens here: https://github.com/mvdan/sh/blob/b717ad599e17a6975e15a67ed8937bd8d4909146/interp/builtin.go#L793
I suppose, the issue is with mvdan/sh
library, but anyway I think it should be handled in this project.
Also, could you please explain, why don't you use recovery while running cmd that potentially panics? I have seen panics from sh interpreter in multiple versions, however now I have only this issue.
In recovery handler you could, for example, capture error message from CMD, but if you want stacktraces, you could manually add them to recovery logs.
Full panic stacktraces are below.
> task
task: [default] nginx -p "/Users/posidoni/powx/cicd/nginx" -c ./nginx.conf -T
panic: runtime error: index out of range [-1]
goroutine 1 gp=0x140000021c0 m=4 mp=0x14000100008 [running]:
panic({0x1030acd60?, 0x1400003a588?})
/opt/homebrew/opt/go/libexec/src/runtime/panic.go:802 +0x150 fp=0x14000593a50 sp=0x140005939a0 pc=0x1026384b0
runtime.goPanicIndex(0xffffffffffffffff, 0x36)
/opt/homebrew/opt/go/libexec/src/runtime/panic.go:115 +0x70 fp=0x14000593a90 sp=0x14000593a50 pc=0x102600910
mvdan.cc/sh/v3/interp.(*Runner).builtin(0x140002c38c8, {0x103107db0, 0x1400017c780}, {0x0, 0x4001}, {0x140004964c8, 0x5}, {0x140003dc410, 0x2, 0x3})
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/builtin.go:729 +0x4d70 fp=0x14000594bb0 sp=0x14000593a90 pc=0x1027e29e0
mvdan.cc/sh/v3/interp.(*Runner).call(0x140002c38c8, {0x103107db0, 0x1400017c780}, {0x3dc410?, 0x140?}, {0x140003dc400, 0x3, 0x4})
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:1031 +0x5a4 fp=0x14000594ca0 sp=0x14000594bb0 pc=0x1027ed414
mvdan.cc/sh/v3/interp.(*Runner).cmd(0x140002c38c8, {0x103107db0, 0x1400017c780}, {0x103106b90, 0x1400045aaa0})
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:458 +0x1c5c fp=0x140005951f0 sp=0x14000594ca0 pc=0x1027eabcc
mvdan.cc/sh/v3/interp.(*Runner).stmtSync(0x140002c38c8, {0x103107db0, 0x1400017c780}, 0x140003862a0)
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:340 +0x158 fp=0x14000595290 sp=0x140005951f0 pc=0x1027e8dc8
mvdan.cc/sh/v3/interp.(*Runner).stmt(0x140002c38c8, {0x103107db0, 0x1400017c780}, 0x140003862a0)
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:322 +0x22c fp=0x14000595310 sp=0x14000595290 pc=0x1027e8b5c
mvdan.cc/sh/v3/interp.(*Runner).stmts(...)
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:829
mvdan.cc/sh/v3/interp.(*Runner).Run(0x140002c38c8, {0x103107db0, 0x1400017c780}, {0x1031043f8, 0x140003dc340})
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/api.go:901 +0x32c fp=0x140005953b0 sp=0x14000595310 pc=0x1027dd29c
github.com/go-task/task/v3/internal/execext.RunCommand({0x103107db0, 0x1400017c780}, 0x140005957b8)
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/internal/execext/exec.go:80 +0x5a4 fp=0x140005955b0 sp=0x140005953b0 pc=0x102989024
github.com/go-task/task/v3.(*Executor).runCommand(0x140001ca420, {0x103107db0, 0x1400017c780}, 0x14000372248, 0x140002def00?, 0x0?)
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:345 +0x578 fp=0x14000595860 sp=0x140005955b0 pc=0x102bcbaa8
github.com/go-task/task/v3.(*Executor).RunTask.func1({0x103107db0, 0x1400017c780})
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:217 +0x680 fp=0x14000595a20 sp=0x14000595860 pc=0x102bca770
github.com/go-task/task/v3.(*Executor).startExecution(0x140001ca420, {0x103107db0, 0x1400017c780}, 0x1025dc2bc?, 0x14000595b80)
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:376 +0x348 fp=0x14000595af0 sp=0x14000595a20 pc=0x102bcc1e8
github.com/go-task/task/v3.(*Executor).RunTask(0x140001ca420, {0x103107db0, 0x1400017c780}, 0x140002def00)
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:153 +0x188 fp=0x14000595bb0 sp=0x14000595af0 pc=0x102bc9ee8
github.com/go-task/task/v3.(*Executor).Run(0x140001ca420, {0x103107d40, 0x1036600a0}, {0x140003c5d88, 0x1, 0x4})
❯❯3_ ❯❯3… /powx/cicd/nginx 21:14 /main +/- [⚡IOT]
> task -v
task: "default" started
task: [default] nginx -p "/Users/posidoni/powx/cicd/nginx" -c ./nginx.conf -T
panic: runtime error: index out of range [-1]
goroutine 1 gp=0x140000021c0 m=10 mp=0x14000386008 [running]:
panic({0x101100d60?, 0x1400051a150?})
/opt/homebrew/opt/go/libexec/src/runtime/panic.go:802 +0x150 fp=0x14000413a50 sp=0x140004139a0 pc=0x10068c4b0
runtime.goPanicIndex(0xffffffffffffffff, 0x36)
/opt/homebrew/opt/go/libexec/src/runtime/panic.go:115 +0x70 fp=0x14000413a90 sp=0x14000413a50 pc=0x100654910
mvdan.cc/sh/v3/interp.(*Runner).builtin(0x14000295b88, {0x10115bdb0, 0x1400017c780}, {0x0, 0x4001}, {0x140004bc620, 0x5}, {0x140003d2550, 0x2, 0x3})
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/builtin.go:729 +0x4d70 fp=0x14000414bb0 sp=0x14000413a90 pc=0x1008369e0
mvdan.cc/sh/v3/interp.(*Runner).call(0x14000295b88, {0x10115bdb0, 0x1400017c780}, {0x3d2550?, 0x140?}, {0x140003d2540, 0x3, 0x4})
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:1031 +0x5a4 fp=0x14000414ca0 sp=0x14000414bb0 pc=0x100841414
mvdan.cc/sh/v3/interp.(*Runner).cmd(0x14000295b88, {0x10115bdb0, 0x1400017c780}, {0x10115ab90, 0x14000312870})
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:458 +0x1c5c fp=0x140004151f0 sp=0x14000414ca0 pc=0x10083ebcc
mvdan.cc/sh/v3/interp.(*Runner).stmtSync(0x14000295b88, {0x10115bdb0, 0x1400017c780}, 0x14000280180)
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:340 +0x158 fp=0x14000415290 sp=0x140004151f0 pc=0x10083cdc8
mvdan.cc/sh/v3/interp.(*Runner).stmt(0x14000295b88, {0x10115bdb0, 0x1400017c780}, 0x14000280180)
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:322 +0x22c fp=0x14000415310 sp=0x14000415290 pc=0x10083cb5c
mvdan.cc/sh/v3/interp.(*Runner).stmts(...)
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/runner.go:829
mvdan.cc/sh/v3/interp.(*Runner).Run(0x14000295b88, {0x10115bdb0, 0x1400017c780}, {0x1011583f8, 0x140003d24c0})
/Users/posidoni/.cache/go/modcache/mvdan.cc/sh/[email protected]/interp/api.go:901 +0x32c fp=0x140004153b0 sp=0x14000415310 pc=0x10083129c
github.com/go-task/task/v3/internal/execext.RunCommand({0x10115bdb0, 0x1400017c780}, 0x140004157b8)
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/internal/execext/exec.go:80 +0x5a4 fp=0x140004155b0 sp=0x140004153b0 pc=0x1009dd024
github.com/go-task/task/v3.(*Executor).runCommand(0x140001ca420, {0x10115bdb0, 0x1400017c780}, 0x14000332248, 0x140002b4f40?, 0x0?)
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:345 +0x578 fp=0x14000415860 sp=0x140004155b0 pc=0x100c1faa8
github.com/go-task/task/v3.(*Executor).RunTask.func1({0x10115bdb0, 0x1400017c780})
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:217 +0x680 fp=0x14000415a20 sp=0x14000415860 pc=0x100c1e770
github.com/go-task/task/v3.(*Executor).startExecution(0x140001ca420, {0x10115bdb0, 0x1400017c780}, 0x1006302bc?, 0x14000415b80)
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:376 +0x348 fp=0x14000415af0 sp=0x14000415a20 pc=0x100c201e8
github.com/go-task/task/v3.(*Executor).RunTask(0x140001ca420, {0x10115bdb0, 0x1400017c780}, 0x140002b4f40)
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:153 +0x188 fp=0x14000415bb0 sp=0x14000415af0 pc=0x100c1dee8
github.com/go-task/task/v3.(*Executor).Run(0x140001ca420, {0x10115bd40, 0x1016b40a0}, {0x14000325d88, 0x1, 0x4})
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/task.go:87 +0x314 fp=0x14000415c70 sp=0x14000415bb0 pc=0x100c1d9f4
main.run()
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/cmd/task/task.go:181 +0x740 fp=0x14000415e90 sp=0x14000415c70 pc=0x100c2cb30
main.main()
/Users/posidoni/.cache/go/modcache/github.com/go-task/task/[email protected]/cmd/task/task.go:23 +0x20 fp=0x14000415f40 sp=0x14000415e90 pc=0x100c2c110
runtime.main()
/opt/homebrew/opt/go/libexec/src/runtime/proc.go:285 +0x278 fp=0x14000415fd0 sp=0x14000415f40 pc=0x100659918
runtime.goexit({})
Version
3.45.4
Operating system
mac
Experiments Enabled
No response
Example Taskfile
---
version: '3.40'
set:
- e
- u
shopt:
- pipefail ### INFO: issue is here
tasks:
default:
cmds:
- echo 123