Panic: runtime error: invalid memory address or nil pointer dereference

Every time I start hugo server or an actual hugo build I get this error. What is interesting is that when I try it again 1-2 times the problem disappears

hugo server

Building sites … WARN 2019/08/02 16:43:01 Page's .URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url.

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

goroutine 469 [running]:
github.com/gohugoio/hugo/hugolib.(*pageState).getLayoutDescriptor.func1()
        /private/tmp/hugo-20190518-58253-nn5aqm/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/page.go:297 +0x334
sync.(*Once).Do(0xc000dda3a8, 0xc03aed3828)
        /usr/local/Cellar/go/1.12.5/libexec/src/sync/once.go:44 +0xb3
github.com/gohugoio/hugo/hugolib.(*pageState).getLayoutDescriptor(0xc000a7fbf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /private/tmp/hugo-20190518-58253-nn5aqm/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/page.go:287 +0x84
github.com/gohugoio/hugo/hugolib.(*pageState).getLayouts(0xc000a7fbf0, 0x0, 0x0, 0x0, 0xc00222db30, 0x3e, 0xc000a668d0, 0xc0032e8580, 0x8)
        /private/tmp/hugo-20190518-58253-nn5aqm/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/page.go:324 +0x15e
github.com/gohugoio/hugo/hugolib.pageRenderer(0xc002417bc0, 0xc0000c4700, 0xc00363e900, 0xc00283b920, 0xc0021b6220)
        /private/tmp/hugo-20190518-58253-nn5aqm/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/site_render.go:139 +0x236
created by github.com/gohugoio/hugo/hugolib.(*Site).renderPages
        /private/tmp/hugo-20190518-58253-nn5aqm/hugo-0.55.6/src/github.com/gohugoio/hugo/hugolib/site_render.go:73 +0x160

It is not hard for me to rerun this command locally few times, but it becomes a huge problem on CI build workflow

If you share your code, or create a minimal reproducible example and share that, we can try to help.

1 Like

I’m not sure what part of the project I need to share (I can’t share everything)
Are there some commands which will help me in my investigation?

Just enough to reproduce the issue.

There is the --debug flag

1 Like

There are not many clues in
hugo server --debug
Just the same error without any additional info about the causes.
But searching in other support posts gave me a hint which looks like a working fix.

config.toml
debug = 100000

(x10 from default)
I assume that the problem is I have a lot of images which needs to be resized. Don’t know why the cached ones is not enough, but this helps (I hope)g

Which config setting did you change, debug or timeout ?

I ran
hugo server --debug
Then added this to config.toml:
timeout = 100000

That makes sense. You may want to edit your post then.

1 Like