Hugo server SIGSEGV fault (Hugo v0.50+)

Hello,

I don’t know how to faithfully reproduce this panic each time. But I get this almost always when I am batch producing the markdown content files for Hugo using ox-hugo.

The terminal looks like this:

Change detected, rebuilding site
2018-11-06 17:29:26.155 -0500
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/multiple-example-blocks-inside-quote-block.md": WRITE
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/source-block-inside-quote-block-and-another-source-block.md": WRITE
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/example-blocks-inside-quote-block-and-another-example-block.md": WRITE
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/source-block-followed-by-a-quote-block-containing-another-source-block.md": WRITE
Total in 3916 ms

Change detected, rebuilding site
2018-11-06 17:29:31.966 -0500
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/parsing-date-from-closed-property.md": WRITE
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/parsing-date-for-a-post-which-begins-with-a-subheading.md": WRITE
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/invalid-date.md": WRITE
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/lastmod-date-org-time-stamp.md": WRITE
Source changed "/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content/posts/lastmod-date-hugo-compatible-date.md": WRITE
Total in 3902 ms
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xcb0d59]

goroutine 1215 [running]:
github.com/gohugoio/hugo/hugolib.(*HugoSites).GetContentPage(0x0, 0xc00054c120, 0x8f, 0x1)
        /home/kmodi/go.apps/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:129 +0x29
github.com/gohugoio/hugo/commands.(*commandeer).handleEvents(0xc0002d0180, 0xc004d0d7e0, 0xc0042946b8, 0xc001e50c00, 0x14, 0x20, 0xc0041b4360)
        /home/kmodi/go.apps/src/github.com/gohugoio/hugo/commands/hugo.go:969 +0x912
github.com/gohugoio/hugo/commands.(*commandeer).newWatcher.func1(0xc004d0d7e0, 0xc0002d0180, 0xc0042946b8, 0xc0041b4360)
        /home/kmodi/go.apps/src/github.com/gohugoio/hugo/commands/hugo.go:730 +0x1d8
created by github.com/gohugoio/hugo/commands.(*commandeer).newWatcher
        /home/kmodi/go.apps/src/github.com/gohugoio/hugo/commands/hugo.go:726 +0x26e
make: *** [Makefile:153: server] Error 2

Is that backtrace adequate to debug and fix this issue?

I believe have been seeing this on and off (again, not consistently) since Hugo v0.50.


Steps to take that might reproduce this

  1. Clone https://github.com/kaushalmodi/ox-hugo
  2. cd to that terminal and run make server HUGO_BASE_DIR=test/site PORT=5555 (this basically runs hugo server in the correct site directory)
  3. Open another terminal and cd to that same cloned git repo dir.
  4. Run make test. This will start a series of Markdown content file production (~400 files) [this step requires Emacs 25.1+ to be installed on your system].

The hugo server running in the first terminal will die somewhere in between while make test is running.

Sorry, I don’t have a smaller recipe to reproduce this problem, but hoping that the panic backtrace helps.

1 Like

I would guess that you also edit the config file at the same time, which I guess could create this race.

No, the config file isn’t touched at all in this. The make test just generates a lot of content Markdown files in short time. Only the content/ dir files are modified.

I tested your site/script, and it eventually fails in the script:

(re-search-forward "^#\\+title:" nil :noerror))))) (if title (setq do-export t) (setq err t) (setq msg (concat "The file neither contains a valid Hugo post subtree, " "nor has the #+title keyword"))))) (if do-export nil (let ((error-fn (if (or (not err) noerror) (function message) (function user-error)))) (apply error-fn (list (format "%s: %s" f-or-b-name msg))))))) (if do-export (progn (org-hugo-export-to-md async subtree visible-only)))))))) (set-window-configuration wconfig))))
  org-hugo-export-wim-to-md(:all-subtrees nil nil :noerror)
  org-hugo-export-all-wim-to-md()
  command-line-1(("--eval" "(progn(setenv \"OX_HUGO_ELPA\" \"/var/folders/n6/s_85mm8d31j6yctssnmn_g1r0000gn/T//bep/ox-hugo-dev/\")(setenv \"TEST_ENABLED\" \"1\")(load-file (expand-file-name \"setup-ox-hugo.el\" \"/Users/bep/dev/dump/ox-hugo/test\")))" "/Users/bep/dev/dump/ox-hugo/test/site/content-org/all-posts.org" "-f" "org-hugo-export-all-wim-to-md" "--kill"))
  command-line()
  normal-top-level()

make[2]: *** [emacs-batch] Error 255
make[1]: *** [md1] Error 2
make: *** [/Users/bep/dev/dump/ox-hugo/test/site/content-org/all-posts.org] Error 2

But there are no errors/panics in the server. I’m on macOS.

Thanks for trying. Most likely (I’ll need to see the full backtrace) it’s failing because you have a much older Emacs version, which is the default on macOS. The top of the backtrace should be mentioning a package called “vc-git”. To fix that, you need at least Emacs 25.1.

I did brew install emacs… so it should be pretty new. If you can create a failing case that does not require special setup, I will look at it. It doesn’t look like a situation that will hit the “common man”.

Few more questions so that at least I can understand what’s going on.

What is your emacs version (output of emacs --version)? I am not a macOS user, so not sure if something special needs to be done to force update an existing package.

Also, please post the full backtrace of that error you get.

OK, I will see if I can come up with a bash script that just loops through all the files in the content/ dir and just does touch on each .md file … may be that reproduces the problem …

I tried to reproduce today. Also need pandoc installed. Emacs script fails for unknown reason:

  org-hugo-export-wim-to-md(:all-subtrees nil nil :noerror)
  org-hugo-export-all-wim-to-md()
  command-line-1(("--eval" "(progn(setenv \"OX_HUGO_ELPA\" \"/tmp/user/ox-hugo-dev/\")(setenv \"TEST_ENABLED\" \"1\")(load-file (expand-file-name \"setup-ox-hugo.el\" \"/github.com/kausha
lmodi/ox-hugo/test\")))" "/github.com/kaushalmodi/ox-hugo/test/site/content-org/all-posts.org" "-f" "org-hugo-export-all-wim-to-md" "--kill"))
  command-line()
  normal-top-level()

Makefile:108: recipe for target 'emacs-batch' failed
make[2]: *** [emacs-batch] Error 255
Makefile:119: recipe for target 'md1' failed
make[1]: *** [md1] Error 2
Makefile:174: recipe for target '/github.com/kaushalmodi/ox-hugo/test/site/content-org/all-posts.org' failed
make: *** [/github.com/kaushalmodi/ox-hugo/test/site/content-org/all-posts.org] Error 2

Using Emacs 25.2.2.

Even so, I do get a panic with the latest Hugo master:

Change detected, rebuilding site
2018-11-10 07:42:10.039 -0600
Source changed "/github.com/kaushalmodi/ox-hugo/test/site/content/section-a/post-a1.md": WRITE
Source changed "/github.com/kaushalmodi/ox-hugo/test/site/content/section-a/post-ax.md": WRITE
Source changed "/github.com/kaushalmodi/ox-hugo/test/site/content/posts/post-with-toc-keyword-0.md": WRITE
panic: no pageOutput

goroutine 29675 [running]:
github.com/gohugoio/hugo/hugolib.pageRenderer(0xc0017ac000, 0xc0067c0660, 0xc0067c0600, 0xc00b10bd00)
        /github.com/gohugoio/hugo/hugolib/site_render.go:119 +0xd24
created by github.com/gohugoio/hugo/hugolib.(*Site).renderPages
        /github.com/gohugoio/hugo/hugolib/site_render.go:43 +0x160

The last file /github.com/kaushalmodi/ox-hugo/test/site/content/posts/post-with-toc-keyword-0.md is empty, which likely causes this new panic.