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

fix: add nil guards in dependency merge #1263

Merged
merged 1 commit into from
Jul 25, 2023

Conversation

neomantra
Copy link
Contributor

I accidentally had an empty deps row in a nested config, like so:

tasks:
  task-name:
    deps:
      - dep-task-name 
      - # commented-out-task-name  , but at wrong place!

This caused a panic like this:

> task --version
Task version: 3.27.1

> task
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1028c0fb0]

goroutine 1 [running]:
github.com/go-task/task/v3/taskfile.Merge.func1({0x140001dc350, 0xe}, 0x140001fb0e0)
        github.com/go-task/task/v3/taskfile/merge.go:44 +0xd0
github.com/go-task/task/v3/internal/orderedmap.(*OrderedMap[...]).Range(0x102a1c5e0, 0x140001337a8)
        github.com/go-task/task/v3/internal/orderedmap/orderedmap.go:114 +0xa4
github.com/go-task/task/v3/taskfile.Merge(0x140001347e0, 0x14000200fc0, 0x14000064fc0, {0x14000133900, 0x1, 0x1})
        github.com/go-task/task/v3/taskfile/merge.go:33 +0x23c
github.com/go-task/task/v3/taskfile/read.Taskfile.func2({0x14000015410, 0x8}, {{0x140000163f0, 0x17}, {0x14000015440, 0xa}, 0x0, 0x0, {0x0, 0x0, ...}, ...})
        github.com/go-task/task/v3/taskfile/read/taskfile.go:158 +0x6c4
github.com/go-task/task/v3/taskfile.(*IncludedTaskfiles).Range(0x14000062800, 0x14000133ba8)
        github.com/go-task/task/v3/taskfile/included_taskfile.go:80 +0x134
github.com/go-task/task/v3/taskfile/read.Taskfile(0x14000079440)
        github.com/go-task/task/v3/taskfile/read/taskfile.go:75 +0x160
github.com/go-task/task/v3.(*Executor).readTaskfile(0x14000001180)
        github.com/go-task/task/v3/setup.go:79 +0x94
github.com/go-task/task/v3.(*Executor).Setup(0x14000001180)
        github.com/go-task/task/v3/setup.go:30 +0x2c
main.run()
        github.com/go-task/task/v3/cmd/task/task.go:250 +0xdb4
main.main()
        github.com/go-task/task/v3/cmd/task/task.go:77 +0x20

There was an unguarded nil pointer dereference in github.com/go-task/task/v3/taskfile/merge.go:44.

@andreynering andreynering added the type: bug Something not working as intended. label Jul 25, 2023
@andreynering
Copy link
Member

Thanks @neomantra!

@andreynering andreynering merged commit 364ddef into go-task:main Jul 25, 2023
11 checks passed
andreynering added a commit that referenced this pull request Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something not working as intended.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants