Repository: gohugoio/hugo (language: go)

Issue:
Hugo crashing with `fatal error: concurrent map iteration and map write`
Note: I know there have been previous issues with this title but they should've been fixed in  v0.138.0. I'm using a newer version and it's still happenning.

The total number of generated pages is fairly large (120k+) and this issue happens fairly often but is fixed on retry.
If it matters I'm using heavily using  the `Content adapters` feature.

```
hugo v0.139.2-770f548b47b39e6f0fd4da1cc80552024e5829e1 linux/amd64 BuildDate=2024-11-23T15:33:51Z VendorInfo=hugomods

fatal error: concurrent map iteration and map write

goroutine 51 [running]:
reflect.mapiternext(0x19fb280?)
        /usr/local/go/src/runtime/map.go:1537 +0x13
reflect.Value.MapKeys({0x1a79ac0?, 0xc0010f58c0?, 0x4f6186c552af4e6f?})
        /usr/local/go/src/reflect/value.go:1852 +0x118
github.com/gohugoio/hashstructure.(*walker).visit(0xc01b0f42f0, {0x1a51c40?, 0xc0010e6a40?, 0xcb268ed8ff68407c?}, 0x0)
        /go/pkg/mod/github.com/gohugoio/hashstructure@v0.1.0/hashstructure.go:218 +0x1625
github.com/gohugoio/hashstructure.(*walker).visit(0xc01b0f42f0, {0x1a51c40?, 0xc01d42b770?, 0x19fb280?}, 0x0)
        /go/pkg/mod/github.com/gohugoio/hashstructure@v0.1.0/hashstructure.go:365 +0x977
github.com/gohugoio/hashstructure.(*walker).visit(0xc01b0f42f0, {0x1a51c40?, 0xc01d42b4d0?, 0x19fb280?}, 0x0)
        /go/pkg/mod/github.com/gohugoio/hashstructure@v0.1.0/hashstructure.go:235 +0x17e5
github.com/gohugoio/hashstructure.(*walker).visit(0xc01b0f42f0, {0x1a51c40?, 0xc01d42b470?, 0x19fb280?}, 0x0)
        /go/pkg/mod/github.com/gohugoio/hashstructure@v0.1.0/hashstructure.go:235 +0x17e5
github.com/gohugoio/hashstructure.(*walker).visit(0xc01b0f42f0, {0x1a79ac0?, 0xc01d371290?, 0x1aa2fe0?}, 0x0)
        /go/pkg/mod/github.com/gohugoio/hashstructure@v0.1.0/hashstructure.go:235 +0x17e5
github.com/gohugoio/hashstructure.Hash({0x1a79ac0, 0xc01d371290}, 0x0?)
        /go/pkg/mod/github.com/gohugoio/hashstructure@v0.1.0/hashstructure.go:102 +0x1c9
github.com/gohugoio/hugo/common/hashing.HashUint64({0xc01b0f4408?, 0x1451185?, 0x19fb280?})
        /src/common/hashing/hashing.go:109 +0xc5
github.com/gohugoio/hugo/hugolib/pagesfromdata.(*BuildState).hash(...)
        /src/hugolib/pagesfromdata/pagesfromgotmpl.go:223
github.com/gohugoio/hugo/hugolib/pagesfromdata.(*BuildState).checkHasChangedAndSetSourceInfo(0xc0006866c0, {0xc01d420a98, 0xa}, {0x1a79ac0?, 0xc01d371290?})
        /src/hugolib/pagesfromdata/pagesfromgotmpl.go:227 +0x4b
github.com/gohugoio/hugo/hugolib/pagesfromdata.(*pagesFromDataTemplateContext).AddPage(0xc000428eb8, {0x1a79ac0?, 0xc01d371290?})
        /src/hugolib/pagesfromdata/pagesfromgotmpl.go:87 +0x58
reflect.Value.call({0x1b450a0?, 0xc000428eb8?, 0x15?}, {0x1c81dcf, 0x4}, {0xc01d345050, 0x1, 0x0?})
        /usr/local/go/src/reflect/value.go:581 +0xca6
reflect.Value.Call({0x1b450a0?, 0xc000428eb8?, 0x194?}, {0xc01d345050?, 0x7fc239216a68?, 0x1a51c40?})
        /usr/local/go/src/reflect/value.go:365 +0xb9
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.safeCall({0x1b450a0?, 0xc000428eb8?, 0xc011281d60?}, {0xc01d345050?, 0x2197640?, 0x1a51c40?})
        /src/tpl/internal/go_templates/texttemplate/funcs.go:375 +0x86
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCall(0xc01b0f58d8, {0x1a51c40?, 0xc011281d60?, 0x0?}, {0x1b450a0?, 0xc000428eb8?, 0x0?}, 0x0, {0x217a118, 0xc00068d7a0}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:360 +0xe68
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalField(0xc01b0f58d8, {0x1a51c40?, 0xc011281d60?, 0x99?}, {0xc000485ac2, 0x7}, {0x217a118, 0xc00068d7a0}, {0xc0000e2ca0, 0x2, ...}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:190 +0x3db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFieldChain(0xc01b0f58d8, {0x1a51c40?, 0xc011281d60?, 0x4122be?}, {0x1b450a0?, 0xc000428eb8?, 0xc011281d60?}, {0x217a118, 0xc00068d7a0}, {0xc0000e2c90, ...}, ...)
        /src/tpl/internal/go_templates/texttemplate/exec.go:613 +0x1d5
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalVariableNode(0xc01b0f58d8, {0x1a51c40?, 0xc011281d60?, 0xc01b0f58d8?}, 0xc00068d7a0, {0xc0000e2ca0, 0x2, 0x2}, {0x1a97d60, 0x3277740, ...})
        /src/tpl/internal/go_templates/texttemplate/exec.go:601 +0x185
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCommand(0xc01b0f58d8, {0x1a51c40?, 0xc011281d60?, 0x0?}, 0xc00068d740, {0x1a97d60?, 0x3277740?, 0xc01b0f5328?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:516 +0xe5
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalPipeline(0xc01b0f58d8, {0x1a51c40?, 0xc011281d60?, 0x19fb280?}, 0xc000686b40)
        /src/tpl/internal/go_templates/texttemplate/exec.go:479 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc01b0f58d8, {0x1a51c40?, 0xc011281d60?, 0x4175cb?}, {0x217a238?, 0xc00068d800})
        /src/tpl/internal/go_templates/texttemplate/exec.go:267 +0x14f
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc01b0f58d8, {0x1a51c40?, 0xc011281d60?, 0x100f2776858?}, {0x217a040?, 0xc00068ccc0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange.func2({0x19fb4c0?, 0xc01d429440?, 0xc000428eb8?}, {0x1a51c40?, 0xc011281d60?, 0xc00004f5b8?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:395 +0x2b2
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange(0xc00004f8d8, {0x1b450a0?, 0xc000428eb8?, 0x417305?}, 0xc0001984c0)
        /src/tpl/internal/go_templates/texttemplate/exec.go:403 +0x615
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc00004f8d8, {0x1b450a0?, 0xc000428eb8?, 0x411010?}, {0x217a310?, 0xc0001984c0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:283 +0xcd
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc01b0f58d8, {0x1b450a0?, 0xc000428eb8?, 0x7fc239216108?}, {0x217a040?, 0xc00068ca80?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*Template).executeWithState(0xc000406400?, 0xc0006198d8, {0x1b450a0?, 0xc000428eb8?, 0xc000175c80?})
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:103 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*executer).ExecuteWithContext(0xc0001519b0, {0x2174c60, 0xc00068d890}, {0x7fc1f22dccd8, 0xc000175c80}, {0x2165ce0, 0x3277740}, {0x1b450a0, 0xc000428eb8})
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:90 +0x2f9
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).ExecuteWithContext(0xc0005e97a0, {0x2174c60, 0xc00068d890}, {0x216db90, 0xc000175c80}, {0x2165ce0, 0x3277740}, {0x1b450a0, 0xc000428eb8})
        /src/tpl/tplimpl/template.go:267 +0x634
github.com/gohugoio/hugo/hugolib/pagesfromdata.(*PagesFromTemplate).Execute(0xc0005f1c00, {0x2174b80, 0x3277740})
        /src/hugolib/pagesfromdata/pagesfromgotmpl.go:312 +0x2b9
github.com/gohugoio/hugo/hugolib.(*pageMap).addPagesFromGoTmplFi(0xc0005d54a0, {0x217eba0, 0xc000175bc0}, 0xc000175300)
        /src/hugolib/content_map.go:441 +0x5c6
github.com/gohugoio/hugo/hugolib.(*pageMap).AddFi(0xc0005d54a0, {0x217eba0, 0xc000175bc0}, 0xc000175300)
        /src/hugolib/content_map.go:279 +0xd6
github.com/gohugoio/hugo/hugolib.(*pagesCollector).Collect.func3({0xc000807f38?, 0xc000509718?}, {0x217eba0, 0xc000175bc0})
        /src/hugolib/pages_capture.go:124 +0x65
github.com/gohugoio/hugo/common/rungroup.Run[...].func1()
        /src/common/rungroup/rungroup.go:64 +0xbd
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:78 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 13
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:75 +0x96

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc00051b998?)
        /usr/local/go/src/runtime/sema.go:71 +0x25
sync.(*WaitGroup).Wait(0x1b2d6c0?)
        /usr/local/go/src/sync/waitgroup.go:118 +0x48
golang.org/x/sync/errgroup.(*Group).Wait(0xc0001752c0)
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:56 +0x25
github.com/gohugoio/hugo/commands.(*hugoBuilder).fullBuild(0xc000538a00, 0x0)
        /src/commands/hugobuilder.go:564 +0x325
github.com/gohugoio/hugo/commands.(*hugoBuilder).build(0xc000538a00)
        /src/commands/hugobuilder.go:397 +0x65
github.com/gohugoio/hugo/commands.(*serverCommand).Run.func2(0xc000412460)
        /src/commands/server.go:502 +0x6e
github.com/gohugoio/hugo/commands.(*serverCommand).Run(0xc000412460, {0x0?, 0x0?}, 0x0?, {0x811e7fb500000000?, 0xc000573a20?, 0x0?})
        /src/commands/server.go:503 +0x1f7
github.com/bep/simplecobra.(*Commandeer).compile.func1(0xc000416800?, {0xc0001558c0?, 0x4?, 0x1c81a3f?})
        /go/pkg/mod/github.com/bep/simplecobra@v0.4.0/simplecobra.go:113 +0x4c
github.com/spf13/cobra.(*Command).execute(0xc000578f08, {0xc000155860, 0x6, 0x6})
        /go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc000578308)
        /go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        /go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1050
github.com/bep/simplecobra.(*Exec).Execute(0xc000520480, {0x2174b80?, 0x3277740?}, {0xc000040090?, 0xc0000061c0?, 0xc000006101?})
        /go/pkg/mod/github.com/bep/simplecobra@v0.4.0/simplecobra.go:155 +0xd4
github.com/gohugoio/hugo/commands.Execute({0xc000040090, 0x7, 0x7})
        /src/commands/commandeer.go:68 +0x2f3
main.main()
        /src/main.go:25 +0x56

goroutine 19 [select]:
github.com/gohugoio/hugo/cache/dynacache.(*Cache).start.func1()
        /src/cache/dynacache/dynacache.go:314 +0x8d
created by github.com/gohugoio/hugo/cache/dynacache.(*Cache).start in goroutine 1
        /src/cache/dynacache/dynacache.go:312 +0x9d

goroutine 9 [IO wait]:
internal/poll.runtime_pollWait(0x7fc1f2768598, 0x72)
        /usr/local/go/src/runtime/netpoll.go:351 +0x85
internal/poll.(*pollDesc).wait(0xc0006863c0?, 0xc0007adcdf?, 0x1)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x27
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc0006863c0, {0xc0007adcdf, 0x10000, 0x10000})
        /usr/local/go/src/internal/poll/fd_unix.go:165 +0x27a
os.(*File).read(...)
        /usr/local/go/src/os/file_posix.go:29
os.(*File).Read(0xc000428de0, {0xc0007adcdf?, 0x0?, 0x0?})
        /usr/local/go/src/os/file.go:124 +0x52
github.com/fsnotify/fsnotify.(*inotify).readEvents(0xc0002d4000)
        /go/pkg/mod/github.com/fsnotify/fsnotify@v1.8.0/backend_inotify.go:431 +0xc5
created by github.com/fsnotify/fsnotify.newBufferedBackend in goroutine 1
        /go/pkg/mod/github.com/fsnotify/fsnotify@v1.8.0/backend_inotify.go:195 +0x196

goroutine 10 [select]:
github.com/gohugoio/hugo/watcher.(*Batcher).run(0xc0005fcab0)
        /src/watcher/batcher.go:64 +0xf4
created by github.com/gohugoio/hugo/watcher.New in goroutine 1
        /src/watcher/batcher.go:55 +0x205

goroutine 11 [select]:
github.com/gohugoio/hugo/commands.(*hugoBuilder).newWatcher.func2()
        /src/commands/hugobuilder.go:341 +0x15a
created by github.com/gohugoio/hugo/commands.(*hugoBuilder).newWatcher in goroutine 1
        /src/commands/hugobuilder.go:339 +0x4b5

goroutine 13 [semacquire]:
sync.runtime_Semacquire(0x0?)
        /usr/local/go/src/runtime/sema.go:71 +0x25
sync.(*WaitGroup).Wait(0x3?)
        /usr/local/go/src/sync/waitgroup.go:118 +0x48
golang.org/x/sync/errgroup.(*Group).Wait(0xc000175380)
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:56 +0x25
github.com/gohugoio/hugo/common/rungroup.(*runGroup[...]).Wait(...)
        /src/common/rungroup/rungroup.go:92
github.com/gohugoio/hugo/hugolib.(*pagesCollector).Collect(0xc0006019e0)
        /src/hugolib/pages_capture.go:197 +0x34b
github.com/gohugoio/hugo/hugolib.(*HugoSites).processFiles(0xc000116b00, {0x2174b80, 0x3277740}, {0x217c290, 0xc000224840}, 0xc000175300, {0x0, 0x0, 0x0})
        /src/hugolib/hugo_sites_build.go:1173 +0x2fd
github.com/gohugoio/hugo/hugolib.(*HugoSites).processFull(0x10?, {0x2174b80?, 0x3277740?}, {0x217c290?, 0xc000224840?}, 0x4?)
        /src/hugolib/hugo_sites_build.go:1112 +0x36
github.com/gohugoio/hugo/hugolib.(*HugoSites).process(0xc000116b00, {0x2174b80, 0x3277740}, {0x217c290?, 0xc000224840?}, 0xc000175300, 0xc000607bf0, {0x0, 0x0, 0x0})
        /src/hugolib/hugo_sites_build.go:263 +0x1f6
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func4()
        /src/hugolib/hugo_sites_build.go:148 +0xbd
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc000116b00, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, {0x0, ...})
        /src/hugolib/hugo_sites_build.go:159 +0x6c7
github.com/gohugoio/hugo/commands.(*hugoBuilder).buildSites(0x0?, 0x0)
        /src/commands/hugobuilder.go:425 +0x10d
github.com/gohugoio/hugo/commands.(*hugoBuilder).fullBuild.func3()
        /src/commands/hugobuilder.go:542 +0x1b
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:78 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:75 +0x96

goroutine 14 [chan receive]:
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func3(0xc00025fb90, 0xc00054cbd0)
        /src/hugolib/hugo_sites_build.go:91 +0x7e
created by github.com/gohugoio/hugo/hugolib.(*HugoSites).Build in goroutine 13
        /src/hugolib/hugo_sites_build.go:88 +0x3f9

goroutine 16 [runnable]:
sync.(*Map).Load(0x3249ca0, {0x1b90320, 0xc000821c18})
        /usr/local/go/src/sync/map.go:125 +0x4f
reflect.SliceOf({0x2197640?, 0x19fb280?})
        /usr/local/go/src/reflect/type.go:2228 +0x90
github.com/gohugoio/hugo/common/collections.Slice({0xc01d4ca6d0, 0x1, 0x1})
        /src/common/collections/slice.go:62 +0x165
github.com/gohugoio/hugo/tpl/collections.(*Namespace).Slice(...)
        /src/tpl/collections/collections.go:562
reflect.Value.call({0x1a36a20?, 0xc000150760?, 0x94?}, {0x1c81dcf, 0x4}, {0xc01d4b4330, 0x1, 0x0?})
        /usr/local/go/src/reflect/value.go:581 +0xca6
reflect.Value.Call({0x1a36a20?, 0xc000150760?, 0x194?}, {0xc01d4b4330?, 0x7fc239216f18?, 0x1a51c40?})
        /usr/local/go/src/reflect/value.go:365 +0xb9
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.safeCall({0x1a36a20?, 0xc000150760?, 0xc0010e6a50?}, {0xc01d4b4330?, 0x2197640?, 0x1a51c40?})
        /src/tpl/internal/go_templates/texttemplate/funcs.go:375 +0x86
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCall(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x8?}, {0x1a36a20?, 0xc000150760?, 0x8?}, 0x0, {0x217a3a0, 0xc00080ac60}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:360 +0xe68
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFunction(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x47153d?}, 0x3277740?, {0x217a3a0, 0xc00080ac60}, {0xc000176360, 0x2, 0x2}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:147 +0x36e
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCommand(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x101757c?}, 0xc00080ac60, {0x1a97d60?, 0x3277740?, 0xc0008228d8?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:510 +0x1d4
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalPipeline(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x194?}, 0xc0008084e0)
        /src/tpl/internal/go_templates/texttemplate/exec.go:479 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalArg(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x1a5bec0?}, {0x2197640, 0x1a51c40}, {0x217a1a8, 0xc0008084e0})
        /src/tpl/internal/go_templates/texttemplate/exec.go:890 +0x346
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCall(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x1a51c40?}, {0x1a5bec0?, 0xc000150630?, 0x10158e5?}, 0x0, {0x217a3a0, 0xc00080abd0}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:327 +0x807
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFunction(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x1?}, 0x1?, {0x217a3a0, 0xc00080abd0}, {0xc00080e280, 0x7, 0x8}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:147 +0x36e
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCommand(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x0?}, 0xc00080abd0, {0x1a97d60?, 0x3277740?, 0xc000822fa8?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:510 +0x1d4
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalPipeline(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x19fb280?}, 0xc000808480)
        /src/tpl/internal/go_templates/texttemplate/exec.go:479 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x1a79ac0?}, {0x217a238?, 0xc00080ade0})
        /src/tpl/internal/go_templates/texttemplate/exec.go:267 +0x14f
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0008238d8, {0x1a51c40?, 0xc0010e6a50?, 0x94?}, {0x217a040?, 0xc00080a570?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange.func2({0x19fb4c0?, 0x2e4f248?, 0xc011281d60?}, {0x1a51c40?, 0xc0010e6a50?, 0x0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:395 +0x2b2
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange(0xc0008238d8, {0x1a51c40?, 0xc011281d60?, 0x7fc1f2486ac8?}, 0xc000254780)
        /src/tpl/internal/go_templates/texttemplate/exec.go:403 +0x615
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0008238d8, {0x1a51c40?, 0xc011281d60?, 0x4175cb?}, {0x217a310?, 0xc000254780?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:283 +0xcd
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0008238d8, {0x1a51c40?, 0xc011281d60?, 0x100f27133a8?}, {0x217a040?, 0xc00080a420?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange.func2({0x19fb4c0?, 0xc01d49c2b0?, 0xc0008100b0?}, {0x1a51c40?, 0xc011281d60?, 0xc0008235b8?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:395 +0x2b2
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange(0xc0008238d8, {0x1b450a0?, 0xc0008100b0?, 0x100000008?}, 0xc000254800)
        /src/tpl/internal/go_templates/texttemplate/exec.go:403 +0x615
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0008238d8, {0x1b450a0?, 0xc0008100b0?, 0xc00080b1a0?}, {0x217a310?, 0xc000254800?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:283 +0xcd
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0008238d8, {0x1b450a0?, 0xc0008100b0?, 0x7fc239216a68?}, {0x217a040?, 0xc00080a1e0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*Template).executeWithState(0xc000406400?, 0xc0008238d8, {0x1b450a0?, 0xc0008100b0?, 0xc000254000?})
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:103 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*executer).ExecuteWithContext(0xc0001519b0, {0x2174c60, 0xc00080b170}, {0x7fc1f22dccd8, 0xc000254000}, {0x2165ce0, 0x3277740}, {0x1b450a0, 0xc0008100b0})
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:90 +0x2f9
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).ExecuteWithContext(0xc0005e97a0, {0x2174c60, 0xc00080b170}, {0x216db90, 0xc000254000}, {0x2165ce0, 0x3277740}, {0x1b450a0, 0xc0008100b0})
        /src/tpl/tplimpl/template.go:267 +0x634
github.com/gohugoio/hugo/hugolib/pagesfromdata.(*PagesFromTemplate).Execute(0xc00080e000, {0x2174b80, 0x3277740})
        /src/hugolib/pagesfromdata/pagesfromgotmpl.go:312 +0x2b9
github.com/gohugoio/hugo/hugolib.(*pageMap).addPagesFromGoTmplFi(0xc0005d54a0, {0x217eba0, 0xc000175980}, 0xc000175300)
        /src/hugolib/content_map.go:441 +0x5c6
github.com/gohugoio/hugo/hugolib.(*pageMap).AddFi(0xc0005d54a0, {0x217eba0, 0xc000175980}, 0xc000175300)
        /src/hugolib/content_map.go:279 +0xd6
github.com/gohugoio/hugo/hugolib.(*pagesCollector).Collect.func3({0xc00006d738?, 0xc00006d718?}, {0x217eba0, 0xc000175980})
        /src/hugolib/pages_capture.go:124 +0x65
github.com/gohugoio/hugo/common/rungroup.Run[...].func1()
        /src/common/rungroup/rungroup.go:64 +0xbd
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:78 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 13
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:75 +0x96

```



Discussion / hints:
@IceWreck is the above the full stack trace? It's not obvious to me what's happening here. I can see the "iteration" part of this situation, but not the write.
@bep yes its the full stack trace.

I will try to reproduce and send it again.
Here's another one

```
Start building sites … 
hugo v0.139.2-770f548b47b39e6f0fd4da1cc80552024e5829e1 linux/amd64 BuildDate=2024-11-23T15:33:51Z VendorInfo=hugomods

fatal error: concurrent map read and map write

goroutine 24 [running]:
reflect.mapaccess_faststr(0x1a79ac0?, 0xc0013ff5c0?, {0xc0001d2098?, 0x15?})
        /usr/local/go/src/runtime/map.go:1469 +0x18
reflect.Value.MapIndex({0x1a79ac0?, 0xc0013ff5c0?, 0xc000100008?}, {0x19fb280, 0xc01d77daa0, 0x98})
        /usr/local/go/src/reflect/value.go:1803 +0xbb
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExecHelper).GetMapValue(0xc0001d2098?, {0xc0007892f0?, 0x7f3f18a2b788?}, {0xc0001720c0?, 0x1a79ac0?}, {0x1a79ac0?, 0xc0013ff5c0?, 0x0?}, {0x19fb280, 0xc01d77daa0, ...})
        /src/tpl/tplimpl/template_funcs.go:119 +0x165
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalField(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x10?}, {0xc0001d2098, 0x4}, {0x217a118, 0xc000788870}, {0x0, 0x0, ...}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:225 +0xb0f
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFieldChain(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x10?}, {0x1a51c40?, 0xc010e82020?, 0x417305?}, {0x217a118, 0xc000788870}, {0xc00017e2d0, ...}, ...)
        /src/tpl/internal/go_templates/texttemplate/exec.go:613 +0x1d5
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalVariableNode(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x19fb280?}, 0xc000788870, {0x0, 0x0, 0x0}, {0x1a97d60, 0x3277740, ...})
        /src/tpl/internal/go_templates/texttemplate/exec.go:601 +0x185
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalArg(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x1a56d20?}, {0x2197640, 0x1a51c40}, {0x217a118, 0xc000788870})
        /src/tpl/internal/go_templates/texttemplate/exec.go:888 +0x4b9
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCall(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0xc0007980d0?}, {0x1a56d20?, 0xc00047e670?, 0x513579?}, 0x0, {0x217a3a0, 0xc000788780}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:327 +0x807
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFunction(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x2?}, 0x2?, {0x217a3a0, 0xc000788780}, {0xc000792180, 0x5, 0x8}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:147 +0x36e
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCommand(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x0?}, 0xc000788780, {0x1a97d60?, 0x3277740?, 0xc0007c6fa8?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:510 +0x1d4
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalPipeline(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x19fb280?}, 0xc00079c300)
        /src/tpl/internal/go_templates/texttemplate/exec.go:479 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x1a79ac0?}, {0x217a238?, 0xc000788900})
        /src/tpl/internal/go_templates/texttemplate/exec.go:267 +0x14f
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0007c78d8, {0x1a51c40?, 0xc0013f4a10?, 0x94?}, {0x217a040?, 0xc0007886f0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange.func2({0x19fb4c0?, 0x2e4f228?, 0xc010e82020?}, {0x1a51c40?, 0xc0013f4a10?, 0x0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:395 +0x2b2
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange(0xc0007c78d8, {0x1a51c40?, 0xc010e82020?, 0x1?}, 0xc0001728c0)
        /src/tpl/internal/go_templates/texttemplate/exec.go:403 +0x615
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0007c78d8, {0x1a51c40?, 0xc010e82020?, 0x6bf3fb60?}, {0x217a310?, 0xc0001728c0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:283 +0xcd
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0007c78d8, {0x1a51c40?, 0xc010e82020?, 0x10018a04358?}, {0x217a040?, 0xc0007885a0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange.func2({0x19fb4c0?, 0xc01d7786e0?, 0xc00079a0c8?}, {0x1a51c40?, 0xc010e82020?, 0xc0007c75b8?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:395 +0x2b2
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange(0xc0007c78d8, {0x1b450a0?, 0xc00079a0c8?, 0x417305?}, 0xc000172940)
        /src/tpl/internal/go_templates/texttemplate/exec.go:403 +0x615
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0007c78d8, {0x1b450a0?, 0xc00079a0c8?, 0xc000789320?}, {0x217a310?, 0xc000172940?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:283 +0xcd
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0007c78d8, {0x1b450a0?, 0xc00079a0c8?, 0x7f3f5f88fa68?}, {0x217a040?, 0xc000788360?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*Template).executeWithState(0x1c68948?, 0xc0007c78d8, {0x1b450a0?, 0xc00079a0c8?, 0xc0001720c0?})
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:103 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*executer).ExecuteWithContext(0xc00047f580, {0x2174c60, 0xc0007892f0}, {0x7f3f18a2b788, 0xc0001720c0}, {0x2165ce0, 0x3277740}, {0x1b450a0, 0xc00079a0c8})
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:90 +0x2f9
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).ExecuteWithContext(0xc00072ae10, {0x2174c60, 0xc0007892f0}, {0x216db90, 0xc0001720c0}, {0x2165ce0, 0x3277740}, {0x1b450a0, 0xc00079a0c8})
        /src/tpl/tplimpl/template.go:267 +0x634
github.com/gohugoio/hugo/hugolib/pagesfromdata.(*PagesFromTemplate).Execute(0xc000792080, {0x2174b80, 0x3277740})
        /src/hugolib/pagesfromdata/pagesfromgotmpl.go:312 +0x2b9
github.com/gohugoio/hugo/hugolib.(*pageMap).addPagesFromGoTmplFi(0xc0005d77c0, {0x217eba0, 0xc000151e40}, 0xc000151700)
        /src/hugolib/content_map.go:441 +0x5c6
github.com/gohugoio/hugo/hugolib.(*pageMap).AddFi(0xc0005d77c0, {0x217eba0, 0xc000151e40}, 0xc000151700)
        /src/hugolib/content_map.go:279 +0xd6
github.com/gohugoio/hugo/hugolib.(*pagesCollector).Collect.func3({0xc0007a9f38?, 0xc0007a9f18?}, {0x217eba0, 0xc000151e40})
        /src/hugolib/pages_capture.go:124 +0x65
github.com/gohugoio/hugo/common/rungroup.Run[...].func1()
        /src/common/rungroup/rungroup.go:64 +0xbd
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:78 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 20
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:75 +0x96

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc0002e56c8?)
        /usr/local/go/src/runtime/sema.go:71 +0x25
sync.(*WaitGroup).Wait(0x1b2d6c0?)
        /usr/local/go/src/sync/waitgroup.go:118 +0x48
golang.org/x/sync/errgroup.(*Group).Wait(0xc000403e80)
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:56 +0x25
github.com/gohugoio/hugo/commands.(*hugoBuilder).fullBuild(0xc00055bc80, 0x0)
        /src/commands/hugobuilder.go:564 +0x325
github.com/gohugoio/hugo/commands.(*hugoBuilder).build(0xc00055bc80)
        /src/commands/hugobuilder.go:397 +0x65
github.com/gohugoio/hugo/commands.(*rootCommand).Run.func1(0xc00055bc80?, 0xc000402200?)
        /src/commands/commandeer.go:381 +0x85
github.com/gohugoio/hugo/commands.(*rootCommand).Run(0xc000580640, {0x0?, 0x0?}, 0xc000402200, {0x0?, 0x0?, 0x0?})
        /src/commands/commandeer.go:386 +0x12e
github.com/gohugoio/hugo/commands.(*hugoBuildCommand).Run(0x0?, {0x2174b80?, 0x3277740?}, 0x0?, {0xc0000bb140?, 0xc000371a20?, 0x0?})
        /src/commands/commands.go:72 +0x25
github.com/bep/simplecobra.(*Commandeer).compile.func1(0xc0004ec600?, {0xc0000bb140?, 0x4?, 0x1c81a3f?})
        /go/pkg/mod/github.com/bep/simplecobra@v0.4.0/simplecobra.go:113 +0x4c
github.com/spf13/cobra.(*Command).execute(0xc0001c2308, {0xc0000bb0e0, 0x3, 0x3})
        /go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001c2008)
        /go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        /go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1050
github.com/bep/simplecobra.(*Exec).Execute(0xc000420b78, {0x2174b80?, 0x3277740?}, {0xc000040060?, 0xc0000061c0?, 0xc000006101?})
        /go/pkg/mod/github.com/bep/simplecobra@v0.4.0/simplecobra.go:155 +0xd4
github.com/gohugoio/hugo/commands.Execute({0xc000040060, 0x4, 0x4})
        /src/commands/commandeer.go:68 +0x2f3
main.main()
        /src/main.go:25 +0x56

goroutine 20 [semacquire]:
sync.runtime_Semacquire(0x0?)
        /usr/local/go/src/runtime/sema.go:71 +0x25
sync.(*WaitGroup).Wait(0x3?)
        /usr/local/go/src/sync/waitgroup.go:118 +0x48
golang.org/x/sync/errgroup.(*Group).Wait(0xc000151780)
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:56 +0x25
github.com/gohugoio/hugo/common/rungroup.(*runGroup[...]).Wait(...)
        /src/common/rungroup/rungroup.go:92
github.com/gohugoio/hugo/hugolib.(*pagesCollector).Collect(0xc000750900)
        /src/hugolib/pages_capture.go:197 +0x34b
github.com/gohugoio/hugo/hugolib.(*HugoSites).processFiles(0xc0005dcdc0, {0x2174b80, 0x3277740}, {0x217c290, 0xc00009af00}, 0xc000151700, {0x0, 0x0, 0x0})
        /src/hugolib/hugo_sites_build.go:1173 +0x2fd
github.com/gohugoio/hugo/hugolib.(*HugoSites).processFull(0x10?, {0x2174b80?, 0x3277740?}, {0x217c290?, 0xc00009af00?}, 0x4?)
        /src/hugolib/hugo_sites_build.go:1112 +0x36
github.com/gohugoio/hugo/hugolib.(*HugoSites).process(0xc0005dcdc0, {0x2174b80, 0x3277740}, {0x217c290?, 0xc00009af00?}, 0xc000151700, 0xc00067bbf0, {0x0, 0x0, 0x0})
        /src/hugolib/hugo_sites_build.go:263 +0x1f6
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func4()
        /src/hugolib/hugo_sites_build.go:148 +0xbd
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc0005dcdc0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, {0x0, ...})
        /src/hugolib/hugo_sites_build.go:159 +0x6c7
github.com/gohugoio/hugo/commands.(*hugoBuilder).buildSites(0x0?, 0x0)
        /src/commands/hugobuilder.go:425 +0x10d
github.com/gohugoio/hugo/commands.(*hugoBuilder).fullBuild.func3()
        /src/commands/hugobuilder.go:542 +0x1b
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:78 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:75 +0x96

goroutine 21 [select]:
github.com/gohugoio/hugo/cache/dynacache.(*Cache).start.func1()
        /src/cache/dynacache/dynacache.go:314 +0x8d
created by github.com/gohugoio/hugo/cache/dynacache.(*Cache).start in goroutine 20
        /src/cache/dynacache/dynacache.go:312 +0x9d

goroutine 22 [chan receive]:
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func3(0xc000027f10, 0xc0000a56c0)
        /src/hugolib/hugo_sites_build.go:91 +0x7e
created by github.com/gohugoio/hugo/hugolib.(*HugoSites).Build in goroutine 20
        /src/hugolib/hugo_sites_build.go:88 +0x3f9

goroutine 25 [runnable]:
reflect.mapaccess_faststr(0x1a79ac0?, 0xc001438300?, {0xc00018a278?, 0x4?})
        /usr/local/go/src/runtime/map.go:1468 +0x49
reflect.Value.MapIndex({0x1a79ac0?, 0xc001438300?, 0xc000071508?}, {0x19fb280, 0xc01d7e6320, 0x98})
        /usr/local/go/src/reflect/value.go:1803 +0xbb
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExecHelper).GetMapValue(0xc00018a278?, {0xc000373380?, 0x7f3f18a2b788?}, {0xc000168480?, 0x1a79ac0?}, {0x1a79ac0?, 0xc001438300?, 0xc01d63bd88?}, {0x19fb280, 0xc01d7e6320, ...})
        /src/tpl/tplimpl/template_funcs.go:119 +0x165
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalField(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x8?}, {0xc00018a278, 0x4}, {0x217a118, 0xc000372ff0}, {0x0, 0x0, ...}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:225 +0xb0f
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFieldChain(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x10?}, {0x1a51c40?, 0xc010e82030?, 0x417305?}, {0x217a118, 0xc000372ff0}, {0xc0001647d0, ...}, ...)
        /src/tpl/internal/go_templates/texttemplate/exec.go:613 +0x1d5
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalVariableNode(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0xc01d63bd88?}, 0xc000372ff0, {0x0, 0x0, 0x0}, {0x1a97d60, 0x3277740, ...})
        /src/tpl/internal/go_templates/texttemplate/exec.go:601 +0x185
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalArg(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x1a36a20?}, {0x2197640, 0x1a51c40}, {0x217a118, 0xc000372ff0})
        /src/tpl/internal/go_templates/texttemplate/exec.go:888 +0x4b9
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCall(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x0?}, {0x1a36a20?, 0xc00047e330?, 0x0?}, 0x0, {0x217a3a0, 0xc000372f60}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:327 +0x807
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFunction(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x47153d?}, 0x4?, {0x217a3a0, 0xc000372f60}, {0xc0001647e0, 0x2, 0x2}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:147 +0x36e
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCommand(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x101757c?}, 0xc000372f60, {0x1a97d60?, 0x3277740?, 0xc04a342c58?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:510 +0x1d4
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalPipeline(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x97?}, 0xc000374720)
        /src/tpl/internal/go_templates/texttemplate/exec.go:479 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalArg(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x1a5bec0?}, {0x2197640, 0x1a51c40}, {0x217a1a8, 0xc000374720})
        /src/tpl/internal/go_templates/texttemplate/exec.go:890 +0x346
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCall(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x1a51c40?}, {0x1a5bec0?, 0xc00047e200?, 0x10158e5?}, 0x0, {0x217a3a0, 0xc000372e10}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:327 +0x807
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalFunction(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x1?}, 0x1?, {0x217a3a0, 0xc000372e10}, {0xc000800380, 0x7, 0x8}, ...)
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:147 +0x36e
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalCommand(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x0?}, 0xc000372e10, {0x1a97d60?, 0x3277740?, 0xc04a343328?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:510 +0x1d4
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).evalPipeline(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x19fb280?}, 0xc000374660)
        /src/tpl/internal/go_templates/texttemplate/exec.go:479 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x4175cb?}, {0x217a238?, 0xc000373020})
        /src/tpl/internal/go_templates/texttemplate/exec.go:267 +0x14f
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc04a3438d8, {0x1a51c40?, 0xc010e82030?, 0x10018a5b5f0?}, {0x217a040?, 0xc0003727b0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange.func2({0x19fb4c0?, 0xc01d7de4e0?, 0xc0008040d0?}, {0x1a51c40?, 0xc010e82030?, 0xc0004835b8?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:395 +0x2b2
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walkRange(0xc0004838d8, {0x1b450a0?, 0xc0008040d0?, 0x8?}, 0xc000168bc0)
        /src/tpl/internal/go_templates/texttemplate/exec.go:403 +0x615
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc0004838d8, {0x1b450a0?, 0xc0008040d0?, 0xc0003733b0?}, {0x217a310?, 0xc000168bc0?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:283 +0xcd
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*state).walk(0xc04a3438d8, {0x1b450a0?, 0xc0008040d0?, 0x7f3f5f88f108?}, {0x217a040?, 0xc000372570?})
        /src/tpl/internal/go_templates/texttemplate/exec.go:280 +0x2db
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*Template).executeWithState(0xc00072b710?, 0xc0004838d8, {0x1b450a0?, 0xc0008040d0?, 0xc000168480?})
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:103 +0x125
github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate.(*executer).ExecuteWithContext(0xc00047f580, {0x2174c60, 0xc000373380}, {0x7f3f18a2b788, 0xc000168480}, {0x2165ce0, 0x3277740}, {0x1b450a0, 0xc0008040d0})
        /src/tpl/internal/go_templates/texttemplate/hugo_template.go:90 +0x2f9
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).ExecuteWithContext(0xc00072ae10, {0x2174c60, 0xc000373380}, {0x216db90, 0xc000168480}, {0x2165ce0, 0x3277740}, {0x1b450a0, 0xc0008040d0})
        /src/tpl/tplimpl/template.go:267 +0x634
github.com/gohugoio/hugo/hugolib/pagesfromdata.(*PagesFromTemplate).Execute(0xc000800100, {0x2174b80, 0x3277740})
        /src/hugolib/pagesfromdata/pagesfromgotmpl.go:312 +0x2b9
github.com/gohugoio/hugo/hugolib.(*pageMap).addPagesFromGoTmplFi(0xc0005d77c0, {0x217eba0, 0xc0001580c0}, 0xc000151700)
        /src/hugolib/content_map.go:441 +0x5c6
github.com/gohugoio/hugo/hugolib.(*pageMap).AddFi(0xc0005d77c0, {0x217eba0, 0xc0001580c0}, 0xc000151700)
        /src/hugolib/content_map.go:279 +0xd6
github.com/gohugoio/hugo/hugolib.(*pagesCollector).Collect.func3({0xc000483f38?, 0xc000483f18?}, {0x217eba0, 0xc0001580c0})
        /src/hugolib/pages_capture.go:124 +0x65
github.com/gohugoio/hugo/common/rungroup.Run[...].func1()
        /src/common/rungroup/rungroup.go:64 +0xbd
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:78 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 20
        /go/pkg/mod/golang.org/x/sync@v0.9.0/errgroup/errgroup.go:75 +0x96
make: *** [Makefile:46: build-static-site] Error 2
```
And third one, they all seem a bit different to each other
https://pastebin.com/BeS7RaiH

I ran this one with debug logging - it only has a single log line before the crash.



```
INFO  static: syncing static files to / duration 201.098µs
<crashes somewhere here and never gets to the log line below>
INFO  build:  step process substep collect files 6 files_total 6 pages_total 63070 resources_total 0 duration 11.582527435s
```

Can also reproduce with the latest version of the official build instead of using a container image
https://pastebin.com/EfpgJ4D0
I see (partially) the _what_ but not the _how_, and I haven't been able to guess myself into a failing example.
@IceWreck I need to put this in the backlog for now. If you can somehow share your repo with me or at least provide some more details about how it's set up (e.g. the content adapter template), I can look into it more.
Hey @bep I will try to write a reproducible example that I can publish publicly this week.
Hey @bep 

Sorry for the delay, here is the reproducer for the bug https://bin.abifog.com/drop/dl/owqoo6eouq

I anonymized everything and stripped the website of every page except for the ones that might be triggering the bug. It doesnt need any remote resources, everything is in the data folder.

Look at the makefile, it will run hugo build in a loop and you should see the traceback in one of the iterations.
 

Fix patch:
diff --git a/common/maps/params.go b/common/maps/params.go
index a8cbba55550..819f796e4ba 100644
--- a/common/maps/params.go
+++ b/common/maps/params.go
@@ -303,7 +303,7 @@ func toMergeStrategy(v any) ParamsMergeStrategy {
 }
 
 // PrepareParams
-// * makes all the keys in the given map lower cased and will do so
+// * makes all the keys in the given map lower cased and will do so recursively.
 // * This will modify the map given.
 // * Any nested map[interface{}]interface{}, map[string]interface{},map[string]string  will be converted to Params.
 // * Any _merge value will be converted to proper type and value.
@@ -343,3 +343,42 @@ func PrepareParams(m Params) {
 		}
 	}
 }
+
+// PrepareParamsClone is like PrepareParams, but it does not modify the input.
+func PrepareParamsClone(m Params) Params {
+	m2 := make(Params)
+	for k, v := range m {
+		var retyped bool
+		lKey := strings.ToLower(k)
+		if lKey == MergeStrategyKey {
+			v = toMergeStrategy(v)
+			retyped = true
+		} else {
+			switch vv := v.(type) {
+			case map[any]any:
+				var p Params = cast.ToStringMap(v)
+				v = PrepareParamsClone(p)
+				retyped = true
+			case map[string]any:
+				var p Params = v.(map[string]any)
+				v = PrepareParamsClone(p)
+				retyped = true
+			case map[string]string:
+				p := make(Params)
+				for k, v := range vv {
+					p[k] = v
+				}
+				v = p
+				PrepareParams(p)
+				retyped = true
+			}
+		}
+
+		if retyped || k != lKey {
+			m2[lKey] = v
+		} else {
+			m2[k] = v
+		}
+	}
+	return m2
+}
diff --git a/resources/page/pagemeta/page_frontmatter.go b/resources/page/pagemeta/page_frontmatter.go
index 21789909ec8..60ba0e00a04 100644
--- a/resources/page/pagemeta/page_frontmatter.go
+++ b/resources/page/pagemeta/page_frontmatter.go
@@ -158,8 +158,11 @@ func (p *PageConfig) Compile(basePath string, pagesFromData bool, ext string, lo
 
 	if p.Params == nil {
 		p.Params = make(maps.Params)
+	} else if pagesFromData {
+		p.Params = maps.PrepareParamsClone(p.Params)
+	} else {
+		maps.PrepareParams(p.Params)
 	}
-	maps.PrepareParams(p.Params)
 
 	if p.Content.Markup == "" && p.Content.MediaType == "" {
 		if ext == "" {


Test patch:
diff --git a/common/maps/maps_test.go b/common/maps/maps_test.go
index b4f9c5a3d8a..40c8ac824fc 100644
--- a/common/maps/maps_test.go
+++ b/common/maps/maps_test.go
@@ -73,10 +73,14 @@ func TestPrepareParams(t *testing.T) {
 	for i, test := range tests {
 		t.Run(fmt.Sprint(i), func(t *testing.T) {
 			// PrepareParams modifies input.
+			prepareClone := PrepareParamsClone(test.input)
 			PrepareParams(test.input)
 			if !reflect.DeepEqual(test.expected, test.input) {
 				t.Errorf("[%d] Expected\n%#v, got\n%#v\n", i, test.expected, test.input)
 			}
+			if !reflect.DeepEqual(test.expected, prepareClone) {
+				t.Errorf("[%d] Expected\n%#v, got\n%#v\n", i, test.expected, prepareClone)
+			}
 		})
 	}
 }