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

Stackoverflow when using .Render without argument #11243

Closed
balki opened this issue Jul 12, 2023 · 5 comments · Fixed by #11245
Closed

Stackoverflow when using .Render without argument #11243

balki opened this issue Jul 12, 2023 · 5 comments · Fixed by #11245
Assignees
Milestone

Comments

@balki
Copy link

balki commented Jul 12, 2023

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.115.0 linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

yes


When a template has {{ .Render }}, hugo crashes with stack overflow.

Start building sites … 
hugo v0.115.0 linux/amd64 BuildDate=unknown

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020b1a468 stack=[0xc020b1a000, 0xc040b1a000]
fatal error: stack overflow

runtime stack:
runtime.throw({0x21859cf?, 0x374f140?})
        /usr/lib/go/src/runtime/panic.go:1047 +0x5d fp=0x7ffe62e57d58 sp=0x7ffe62e57d28 pc=0x438c1d
runtime.newstack()
        /usr/lib/go/src/runtime/stack.go:1105 +0x5bd fp=0x7ffe62e57f08 sp=0x7ffe62e57d58 pc=0x4534bd
runtime.morestack()
        /usr/lib/go/src/runtime/asm_amd64.s:574 +0x8b fp=0x7ffe62e57f10 sp=0x7ffe62e57f08 pc=0x46cbab

goroutine 10 [running]:
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).LookupLayout(_, {{0x214ee03, 0x4}, {0x0, 0x0}, {0x214e7b7, 0x4}, {0x0, 0x0}, {0x214a236, ...}, ...}, ...)
        <autogenerated>:1 +0x98 fp=0xc020b1a478 sp=0xc020b1a470 pc=0x1bd1158
github.com/gohugoio/hugo/hugolib.(*pageState).resolveTemplate(0xc0006a2570, {0x39b1e58, 0x0, 0x0?})
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/hugolib/page.go:482 +0x298 fp=0xc020b1a980 sp=0xc020b1a478 pc=0x1bf1058
github.com/gohugoio/hugo/hugolib.(*pageContentOutput).Render(0xc0000ca3c0, {0x2821d48, 0xc0009b8180}, {0x39b1e58?, 0xc020b1aad8?, 0x4aec3e?})
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/hugolib/page__per_output.go:560 +0x5e fp=0xc020b1aa18 sp=0xc020b1a980 pc=0x1c022fe
github.com/gohugoio/hugo/hugolib.(*pageState).Render(0xc0009b8180?, {0x2821d48?, 0xc0009b8180?}, {0x39b1e58?, 0x4?, 0xc000473e30?})
        <autogenerated>:1 +0x47 fp=0xc020b1aa58 sp=0xc020b1aa18 pc=0x1c366a7
runtime.call64(0xc0009b8a20, 0xc00b560e78, 0x0, 0x0, 0x0, 0x30, 0xc020b1afb8)
        /usr/lib/go/src/runtime/asm_amd64.s:730 +0x49 fp=0xc020b1aaa8 sp=0xc020b1aa58 pc=0x46d0e9
runtime.reflectcall(0x1dd22e0?, 0xc00b5c05b8?, 0x8?, 0x219cb50?, 0x0?, 0x12?, 0x1dd22e0?)
        <autogenerated>:1 +0x3c fp=0xc020b1aae8 sp=0xc020b1aaa8 pc=0x47185c
reflect.Value.call({0x213ed80?, 0xc0006a2570?, 0xe20b9b?}, {0x214d33b, 0x4}, {0xc00b5c05a0, 0x1, 0x0?})
        /usr/lib/go/src/reflect/value.go:586 +0xb0b fp=0xc020b1b0d8 sp=0xc020b1aae8 pc=0x4a3eeb
reflect.Value.Call({0x213ed80?, 0xc0006a2570?, 0x17b7998?}, {0xc00b5c05a0?, 0x2837f28?, 0x1f211a0?})
        /usr/lib/go/src/reflect/value.go:370 +0xbc fp=0xc020b1b150 sp=0xc020b1b0d8 pc=0x4a319c
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.safeCall({0x213ed80?, 0xc0006a2570?, 0xc0009b8180?}, {0xc00b5c05a0?, 0x2837f28?, 0x1f211a0?})
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/funcs.go:367 +0x9d fp=0xc020b1b1f0 sp=0xc020b1b150 pc=0x17bbcdd
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCall(0xc020b1bb28, {0x213ed80?, 0xc0006a2570?, 0x0?}, {0x213ed80?, 0xc0006a2570?, 0x4a319c?}, 0x0, {0x2825fe8, 0xc0009b1ef0}, ...)
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/hugo_template.go:365 +0xb25 fp=0xc020b1b350 sp=0xc020b1b1f0 pc=0x17c2425
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalField(0xc020b1bb28, {0x213ed80?, 0xc0006a2570?, 0xc000750270?}, {0xc0001d343e, 0x6}, {0x2825fe8, 0xc0009b1ef0}, {0xc00099beb0, 0x1, ...}, ...)
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/hugo_template.go:199 +0x51c fp=0xc020b1b658 sp=0xc020b1b350 pc=0x17c0cdc
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFieldChain(0xc00b51f800?, {0x213ed80?, 0xc0006a2570?, 0xc0006a2570?}, {0x213ed80?, 0xc0006a2570?, 0x0?}, {0x2825fe8, 0xc0009b1ef0}, {0xc00099bea0, ...}, ...)
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/exec.go:613 +0x1eb fp=0xc020b1b720 sp=0xc020b1b658 pc=0x17b768b
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFieldNode(0x1df8240?, {0x213ed80?, 0xc0006a2570?, 0xc020b1b878?}, 0x1000000503586?, {0xc00099beb0?, 0x7fdb12a6c108?, 0x240?}, {0x1eb1fe0, 0x39b1e58, ...})
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/exec.go:577 +0xce fp=0xc020b1b7c0 sp=0xc020b1b720 pc=0x17b6eee
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCommand(0xc020b1bb28, {0x213ed80?, 0xc0006a2570?, 0x39b1e58?}, 0x1?, {0x1eb1fe0?, 0x39b1e58?, 0xc020b1b910?})
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/exec.go:505 +0xc9 fp=0xc020b1b898 sp=0xc020b1b7c0 pc=0x17b65c9
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalPipeline(0xc020b1bb28, {0x213ed80?, 0xc0006a2570?, 0x4233e5?}, 0xc0009af500)
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/exec.go:479 +0x145 fp=0xc020b1b988 sp=0xc020b1b898 pc=0x17b6045
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc020b1bb28, {0x213ed80?, 0xc0006a2570?, 0x30?}, {0x2825d60?, 0xc0009b1f20})
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/exec.go:267 +0x99 fp=0xc020b1ba28 sp=0xc020b1b988 pc=0x17b4a19
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc020b1bb28, {0x213ed80?, 0xc0006a2570?, 0x214e7db?}, {0x28260c0?, 0xc0009b1e60?})
        /run/host/home/balki/go/pkg/mod/github.com/gohugoio/hugo@v0.115.0/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2d5 fp=0xc020b1bac8 sp=0xc020b1ba28 pc=0x17b4c55
...
@jmooring
Copy link
Member

Can you provide a reproducible example? I am unable to reproduce with v0.115.2.

@balki
Copy link
Author

balki commented Jul 13, 2023

Updated hugo, now in latest version

❯ hugo version   
hugo v0.115.2 linux/amd64 BuildDate=unknown

Following commands reproduce this

hugo new site hugo-crash-repro

cd hugo-crash-repro

echo "{{ .Render }}" > layouts/index.html

hugo

@jmooring
Copy link
Member

OK, I can reproduce, but why would you do this?
https://gohugo.io/functions/render/

Syntax

.Render LAYOUT

@balki
Copy link
Author

balki commented Jul 13, 2023

No reason to do this. Found accidentally. However expect to fail gracefully with an error instead of crashing with stack overflow.

@bep bep changed the title Stackoverflow when using .Render in template Stackoverflow when using .Render without argument Jul 13, 2023
@bep bep removed the NeedsTriage label Jul 13, 2023
@bep bep added this to the v0.115.3 milestone Jul 13, 2023
@bep bep self-assigned this Jul 13, 2023
@bep bep mentioned this issue Jul 13, 2023
bep added a commit to bep/hugo that referenced this issue Jul 13, 2023
bep added a commit that referenced this issue Jul 13, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@balki @jmooring @bep and others