Skip to content

Avoid panic after calling WordsSeq.#2810

Open
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/expand-fields
Open

Avoid panic after calling WordsSeq.#2810
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/expand-fields

Conversation

@trulede
Copy link
Copy Markdown
Contributor

@trulede trulede commented Apr 25, 2026

If the call to WordsSeq (mvdan.sh) returns an error, and that condition is not handled, then the resultant word with value nil is pushed to the list of words. A subsequent call to mvdan.sh will then panic.

This PR handles the error condition.

The panic.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6286b7]

goroutine 1 [running]:
mvdan.cc/sh/v3/expand.FieldsSeq.func1(0xc0004a0930)
        /home/trule/go/pkg/mod/mvdan.cc/sh/v3@v3.12.1-0.20260124232039-e74afc18e65b/expand/expand.go:459 +0x97
mvdan.cc/sh/v3/expand.Fields(0xc00040e000, {0xc000482a80, 0x2, 0x2})
        /home/trule/go/pkg/mod/mvdan.cc/sh/v3@v3.12.1-0.20260124232039-e74afc18e65b/expand/expand.go:442 +0x125
github.com/go-task/task/v3/internal/execext.ExpandFields({0xc0000fe1e0?, 0x2d?})
        /home/trule/git/task/internal/execext/exec.go:139 +0x18e
github.com/go-task/task/v3/internal/fingerprint.glob({0xc00005a600?, 0x10?}, {0xc00005a570?, 0xc000110a20?})
        /home/trule/git/task/internal/fingerprint/glob.go:29 +0x37
github.com/go-task/task/v3/internal/fingerprint.Globs({0xc00005a600, 0x2d}, {0xc000482910, 0x2, 0x2e?})
        /home/trule/git/task/internal/fingerprint/glob.go:15 +0xea
github.com/go-task/task/v3/internal/fingerprint.(*ChecksumChecker).checksum(0x41d8a5?, 0x18?)
        /home/trule/git/task/internal/fingerprint/sources_checksum.go:91 +0x45
github.com/go-task/task/v3/internal/fingerprint.(*ChecksumChecker).Value(0xc0005924c0?, 0x0?)
        /home/trule/git/task/internal/fingerprint/sources_checksum.go:76 +0x13
github.com/go-task/task/v3.(*Executor).compiledTask(0xc0004623c0, 0xc0000cb240, 0x1)
        /home/trule/git/task/variables.go:201 +0x1014
github.com/go-task/task/v3.(*Executor).CompiledTask(...)
        /home/trule/git/task/variables.go:25
github.com/go-task/task/v3.(*Executor).RunTask(0xc0004623c0, {0x22b9750, 0x32f0ae0}, 0xc0000cb240)
        /home/trule/git/task/task.go:159 +0x256
github.com/go-task/task/v3.(*Executor).runCommand(0xc0004623c0, {0x22b9750, 0x32f0ae0}, 0xc00082afc8, 0xc0004c9820, 0x0?)
        /home/trule/git/task/task.go:382 +0x291
github.com/go-task/task/v3.(*Executor).RunTask.func1({0x22b9750, 0x32f0ae0})
        /home/trule/git/task/task.go:275 +0xa1e
github.com/go-task/task/v3.(*Executor).startExecution(0xc0004623c0, {0x22b9750, 0x32f0ae0}, 0xc00082afc8, 0xc000111b60)
        /home/trule/git/task/task.go:445 +0x9c
github.com/go-task/task/v3.(*Executor).RunTask(0xc0004623c0, {0x22b9750, 0x32f0ae0}, 0xc0004c9820)
        /home/trule/git/task/task.go:207 +0x5c5
github.com/go-task/task/v3.(*Executor).Run(0xc0004623c0, {0x22b9750, 0x32f0ae0}, {0xc0005f1d98, 0x1, 0x4})
        /home/trule/git/task/task.go:95 +0x40c

This also fix is also related to #2753

@trulede trulede added the dep: mvdan/sh Issues related to the upstream interpreter used by Task. label Apr 25, 2026
@trulede trulede changed the title Handle the error condition when calling WordsSeq. Avoid panic after calling WordsSeq. Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dep: mvdan/sh Issues related to the upstream interpreter used by Task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant