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

Raise error on missing inn er shortcode template (or something) #6075

Closed
ypujante opened this issue Jul 6, 2019 · 0 comments · Fixed by #6248

Comments

@ypujante
Copy link

commented Jul 6, 2019

I am building a site using hugo and the hugo-theme-learn theme. I was having an issue and decided to comment out the theme section in config.toml and discovered a panic / segmentation fault while running hugo.

> hugo version
Hugo Static Site Generator v0.55.6/extended darwin/amd64 BuildDate: unknown

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

goroutine 86 [running]:
github.com/gohugoio/hugo/hugolib.(*shortcodeHandler).extractShortcode(0xc0005db600, 0x0, 0x0, 0xc0005d39a0, 0x0, 0x4, 0xc0005e38f0)
        /private/tmp/hugo-20190518-89589-zeuvqr/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/shortcode.go:476 +0x333
github.com/gohugoio/hugo/hugolib.(*pageState).mapContent(0xc00066a120, 0xc000356240, 0x4, 0xc0005dcf00)
        /private/tmp/hugo-20190518-89589-zeuvqr/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/page.go:591 +0xaf9
github.com/gohugoio/hugo/hugolib.newPageWithContent(0xc000206440, 0xc000259180, 0xc000670000, 0xc000668050, 0x0, 0x0, 0x0)
        /private/tmp/hugo-20190518-89589-zeuvqr/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/page__new.go:214 +0x482
github.com/gohugoio/hugo/hugolib.(*contentHandlers).parsePage.func1(0xc00060e4c0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /private/tmp/hugo-20190518-89589-zeuvqr/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/pagebundler_handlers.go:200 +0x167
github.com/gohugoio/hugo/hugolib.(*contentHandlers).processFirstMatch.func1(0xc00060e4c0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /private/tmp/hugo-20190518-89589-zeuvqr/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/pagebundler_handlers.go:81 +0x8e
github.com/gohugoio/hugo/hugolib.(*siteContentProcessor).readAndConvertContentFile(...)
        /private/tmp/hugo-20190518-89589-zeuvqr/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/pagebundler.go:200
github.com/gohugoio/hugo/hugolib.(*siteContentProcessor).process.func2(0x8, 0x4e225f8)
        /private/tmp/hugo-20190518-89589-zeuvqr/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/pagebundler.go:131 +0x171
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc00042fb00, 0xc00000ec60)
        /Users/brew/Library/Caches/Homebrew/go_cache/pkg/mod/golang.org/x/sync@v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:58 +0x57
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-20180314180146-1d60e4601c6f/errgroup/errgroup.go:55 +0x66

I am attaching the project that reproduces the issue
panic-www.zip

I believe the issue comes from this section in content/releases/_index.md

{{% release-note date="2019-05-19" version="v3.2.1" %}}

{{% notice warning %}}
The following changes are potentially breaking changes:
{{% /notice %}}

{{% /release-note %}}

Which invokes a shortcode

{{ $_hugo_config := `{ "version": 1 }` }}
<section class="release-note">
<h3><a href="https://acme.com/{{ .Get "version"}}">{{ .Get "date" }} - {{ .Get "version"}}</a></h3>

{{ .Inner }}

</section>

And the notice shortcode is no longer defined because I commented out the theme entirely and this is where it is defined.

Although it is clearly an error I wouldn't expect a panic/memory violation error

@bep bep added this to the v0.56 milestone Jul 21, 2019

@bep bep changed the title panic: runtime error: invalid memory address or nil pointer dereference Raise error on missing inn er shortcode template (or something) Jul 21, 2019

@bep bep added the Bug label Jul 21, 2019

@bep bep modified the milestones: v0.56, v0.57, v0.58 Jul 26, 2019

@bep bep modified the milestones: v0.58, v0.59 Aug 13, 2019

vazrupe added a commit to vazrupe/hugo that referenced this issue Aug 19, 2019
hugolib: Change to output non-panic error message if missing shortcod…
…e template

A panic occurred when the `nested` variable was nil.
Changed to check if the `nested` variable is nil.

Fixes gohugoio#6075

@bep bep closed this in #6248 Aug 22, 2019

bep added a commit that referenced this issue Aug 22, 2019
hugolib: Change to output non-panic error message if missing shortcod…
…e template

A panic occurred when the `nested` variable was nil.
Changed to check if the `nested` variable is nil.

Fixes #6075
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.