Inline shortcode crashing Hugo 0.62

Here is a sample markdown document that works in Hugo 0.61

### Inline Shortcode declaration and first use
{{% reuse.inline %}}A programmer's wife sends him to the grocery with instructions: **Get a loaf of bread and if they have eggs, get a dozen**. He came back with a dozen loafs of bread: **They had eggs.**
{{% /reuse.inline %}}

### Shortcode usage as HTML
{{< reuse.inline />}}

### Shortcode usage as Markup
{{% reuse.inline /%}}

Word pefectly with Hugo 0.61. With Hugo 0.62, I get the following crash log:

Building sites … panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x4b13c9f]

goroutine 67 [running]:
github.com/gohugoio/hugo/hugolib.shortcode.insertPlaceholder(...)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/shortcode.go:199
github.com/gohugoio/hugo/hugolib.(*pageContentMap).AddShortcode(0xc001026980, 0xc00062bb00)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/page__content.go:129 +0xdf
github.com/gohugoio/hugo/hugolib.(*pageState).mapContent(0xc00105a030, 0xc0000e4460, 0xc000140280, 0x0, 0xc000fadbd8)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/page.go:774 +0xcd7
github.com/gohugoio/hugo/hugolib.newPageWithContent.func1(0xc0000e4460, 0x402fdfa, 0xc000fadc30)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/page__new.go:233 +0x4b
github.com/gohugoio/hugo/hugolib.(*pagesMap).initPageMeta.func1()
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/pages_map.go:77 +0x50
sync.(*Once).doSlow(0xc000182520, 0xc000fadca8)
        /usr/local/Cellar/go/1.13.5/libexec/src/sync/once.go:66 +0xe3
sync.(*Once).Do(...)
        /usr/local/Cellar/go/1.13.5/libexec/src/sync/once.go:57
github.com/gohugoio/hugo/hugolib.(*pagesMap).initPageMeta(0xc0010640a0, 0xc00105a030, 0xc0000e4460, 0x585675a, 0x4)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/pages_map.go:75 +0xa1
github.com/gohugoio/hugo/hugolib.(*pagesMap).initPageMetaFor(0xc0010640a0, 0x5852ff6, 0x1, 0xc0000e4460, 0x0, 0x0)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/pages_map.go:95 +0x429
github.com/gohugoio/hugo/hugolib.(*pagesMap).assemblePageMeta.func1(0x5852ff6, 0x1, 0x5646a00, 0xc0000e4460, 0x0)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/pages_map.go:199 +0x66
github.com/armon/go-radix.recursiveWalk(0xc001074330, 0xc000fadea0, 0xc001040010)
        /Users/brew/Library/Caches/Homebrew/go_cache/pkg/mod/github.com/armon/go-radix@v1.0.0/radix.go:519 +0xf0
github.com/armon/go-radix.recursiveWalk(0xc0010681e0, 0xc000fadea0, 0x0)
        /Users/brew/Library/Caches/Homebrew/go_cache/pkg/mod/github.com/armon/go-radix@v1.0.0/radix.go:525 +0x7e
github.com/armon/go-radix.(*Tree).Walk(...)
        /Users/brew/Library/Caches/Homebrew/go_cache/pkg/mod/github.com/armon/go-radix@v1.0.0/radix.go:447
github.com/gohugoio/hugo/hugolib.(*pagesMap).assemblePageMeta(0xc0010640a0, 0xc00060d880, 0x0)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/pages_map.go:196 +0x6c
github.com/gohugoio/hugo/hugolib.(*HugoSites).assemble.func1(0x0, 0x0)
        /private/tmp/hugo-20191223-73775-718ui7/hugo-0.62.0/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:264 +0xff
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc0010742d0, 0xc001074300)
        /Users/brew/Library/Caches/Homebrew/go_cache/pkg/mod/golang.org/x/sync@v0.0.0-20190423024810-112230192c58/errgroup/errgroup.go:57 +0x64
created by golang.org/x/sync/errgroup.(*Group).Go
        /Users/brew/Library/Caches/Homebrew/go_cache/pkg/mod/golang.org/x/sync@v0.0.0-20190423024810-112230192c58/errgroup/errgroup.go:54 +0x66

Please share a project that reproduces the error. :slight_smile:

Please use https://github.com/hugoinaction/hugoinaction/tree/ch06-21

(Note that master branch does not have any code).

1 Like

I see how I stepped wrong. I will fix it, see https://github.com/gohugoio/hugo/issues/6677

1 Like

Note that this crash is with “{{%” delmiter. My main motivation when implemented these inline shortcodes (for the Bootstrap project) was for HTML macros, e.g. “{{<”.