Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Data race in new position handling #14710

@bep

Description

@bep

Ref. 303e443
Looks like you cannot trust Claude to get it 100% right ...

  • Related, I suspect we have some missing test coverage for Position in render hooks triggered via .RenderString
exec: go "test" "-p" "2" "-race" "./resources/page" "-tags" "extended,withdeploy"
WARN  deprecated: cascade._target was deprecated in Hugo v0.156.0 and will be removed in a future release. Use cascade.target instead, see https://gohugo.io/content-management/front-matter/#target
==================
WARNING: DATA RACE
Write at 0x00c0049dcb20 by goroutine 831:
  github.com/gohugoio/hugo/hugolib.(*cachedContentScope).contentToC.func1()
      /home/runner/work/hugo/hugo/hugolib/page__content.go:681 +0x5d8
  github.com/bep/lazycache.(*Cache[go.shape.string,go.shape.*uint8]).GetOrCreate.func1()
      /home/runner/go/pkg/mod/github.com/bep/[email protected]/lazycache.go:146 +0x1b2
  github.com/bep/lazycache.(*Cache[go.shape.string,go.shape.*uint8]).GetOrCreate()
      /home/runner/go/pkg/mod/github.com/bep/[email protected]/lazycache.go:150 +0x304
  github.com/gohugoio/hugo/cache/dynacache.(*Partition[go.shape.string,go.shape.*uint8]).doGetOrCreate()
      /home/runner/work/hugo/hugo/cache/dynacache/dynacache.go:411 +0xc4
  github.com/gohugoio/hugo/cache/dynacache.(*Partition[go.shape.string,go.shape.*uint8]).GetOrCreate()
      /home/runner/work/hugo/hugo/cache/dynacache/dynacache.go:399 +0x47
  github.com/gohugoio/hugo/hugolib.(*cachedContentScope).contentToC()
      /home/runner/work/hugo/hugo/hugolib/page__content.go:640 +0x244
  github.com/gohugoio/hugo/hugolib.(*cachedContentScope).contentRendered.func1()
      /home/runner/work/hugo/hugo/hugolib/page__content.go:497 +0x297
  github.com/bep/lazycache.(*Cache[go.shape.string,go.shape.*uint8]).GetOrCreate.func1()
      /home/runner/go/pkg/mod/github.com/bep/[email protected]/lazycache.go:146 +0x1b2
  github.com/bep/lazycache.(*Cache[go.shape.string,go.shape.*uint8]).GetOrCreate()
      /home/runner/go/pkg/mod/github.com/bep/[email protected]/lazycache.go:150 +0x304
  github.com/gohugoio/hugo/cache/dynacache.(*Partition[go.shape.string,go.shape.*uint8]).doGetOrCreate()
      /home/runner/work/hugo/hugo/cache/dynacache/dynacache.go:411 +0xc4
  github.com/gohugoio/hugo/cache/dynacache.(*Partition[go.shape.string,go.shape.*uint8]).GetOrCreate()
      /home/runner/work/hugo/hugo/cache/dynacache/dynacache.go:399 +0x47
  github.com/gohugoio/hugo/hugolib.(*cachedContentScope).contentRendered()
      /home/runner/work/hugo/hugo/hugolib/page__content.go:488 +0x2c4
  github.com/gohugoio/hugo/hugolib.(*cachedContentScope).Content()
      /home/runner/work/hugo/hugo/hugolib/page__content.go:842 +0x6e
  runtime.call32()
      /home/runner/work/hugo/hugo/hugolib/site_render.go:84 +0x1c7
  github.com/gohugoio/hugo/hugolib.(*Site).render()
      /home/runner/work/hugo/hugo/hugolib/site.go:1769 +0x4c
  github.com/gohugoio/hugo/hugolib.(*HugoSites).render.(*HugoSites).render.(*HugoSites).allSites.func5.(*HugoSites).render-range1.func6()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:468 +0x7f6
  github.com/gohugoio/hugo/hugolib.(*HugoSites).render-range1()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:476 +0xe71
  github.com/gohugoio/hugo/hugolib.(*HugoSites).render.(*HugoSites).allSites.func5()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites.go:173 +0x8ee
  github.com/gohugoio/hugo/hugolib.(*HugoSites).render()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:425 +0xe8b
  github.com/gohugoio/hugo/hugolib.(*HugoSites).Build()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:196 +0x1384
  github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func6()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:176 +0x1114
  github.com/gohugoio/hugo/hugolib.(*HugoSites).Build()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:186 +0x10ca
  github.com/gohugoio/hugo/hugolib.(*IntegrationTestBuilder).build()
      /home/runner/work/hugo/hugo/hugolib/integrationtest_builder.go:1013 +0x2ec
  github.com/gohugoio/hugo/hugolib.(*IntegrationTestBuilder).BuildE()
      /home/runner/work/hugo/hugo/hugolib/integrationtest_builder.go:693 +0x136
  github.com/gohugoio/hugo/hugolib.(*IntegrationTestBuilder).Build()
      /home/runner/work/hugo/hugo/hugolib/integrationtest_builder.go:622 +0x84
  github.com/gohugoio/hugo/hugolib.Test()
      /home/runner/work/hugo/hugo/hugolib/integrationtest_builder.go:149 +0x23c
  github.com/gohugoio/hugo/resources/page_test.TestPageMarkupScope()
      /home/runner/work/hugo/hugo/resources/page/page_markup_integration_test.go:164 +0x64
  testing.tRunner()
      /opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1934 +0x21c
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1997 +0x44

Goroutine 833 (running) created at:
  github.com/gohugoio/hugo/hugolib.(*Site).renderPages()
      /home/runner/work/hugo/hugo/hugolib/site_render.go:84 +0x1c7
  github.com/gohugoio/hugo/hugolib.(*Site).render()
      /home/runner/work/hugo/hugo/hugolib/site.go:1769 +0x4c
  github.com/gohugoio/hugo/hugolib.(*HugoSites).render.(*HugoSites).render.(*HugoSites).allSites.func5.(*HugoSites).render-range1.func6()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:468 +0x7f6
  github.com/gohugoio/hugo/hugolib.(*HugoSites).render-range1()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:476 +0xe71
  github.com/gohugoio/hugo/hugolib.(*HugoSites).render.(*HugoSites).allSites.func5()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites.go:173 +0x8ee
  github.com/gohugoio/hugo/hugolib.(*HugoSites).render()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:425 +0xe8b
  github.com/gohugoio/hugo/hugolib.(*HugoSites).Build()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:196 +0x1384
  github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func6()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:176 +0x1114
  github.com/gohugoio/hugo/hugolib.(*HugoSites).Build()
      /home/runner/work/hugo/hugo/hugolib/hugo_sites_build.go:186 +0x10ca
  github.com/gohugoio/hugo/hugolib.(*IntegrationTestBuilder).build()
      /home/runner/work/hugo/hugo/hugolib/integrationtest_builder.go:1013 +0x2ec
  github.com/gohugoio/hugo/hugolib.(*IntegrationTestBuilder).BuildE()
      /home/runner/work/hugo/hugo/hugolib/integrationtest_builder.go:693 +0x136
  github.com/gohugoio/hugo/hugolib.(*IntegrationTestBuilder).Build()
      /home/runner/work/hugo/hugo/hugolib/integrationtest_builder.go:622 +0x84
  github.com/gohugoio/hugo/hugolib.Test()
      /home/runner/work/hugo/hugo/hugolib/integrationtest_builder.go:149 +0x23c
  github.com/gohugoio/hugo/resources/page_test.TestPageMarkupScope()
      /home/runner/work/hugo/hugo/resources/page/page_markup_integration_test.go:164 +0x64
  testing.tRunner()
      /opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1934 +0x21c
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1997 +0x44
==================
--- FAIL: TestPageMarkupScope (0.16s)
    testing.go:1617: race detected during execution of test
--- FAIL: TestPermalinksNestedSections (0.17s)
    permalinks_integration_test.go:231: 
    testing.go:1617: race detected during execution of test
--- FAIL: TestIssue13968 (0.49s)
    testing.go:1617: race detected during execution of test
--- FAIL: TestPageMarkupWithoutSummaryAsciiDoc (0.35s)
    testing.go:1617: race detected during execution of test
FAIL
FAIL	github.com/gohugoio/hugo/resources/page	1.656s

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions