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

Some data races in tests #1601

Closed
bep opened this issue Nov 22, 2015 · 6 comments
Closed

Some data races in tests #1601

bep opened this issue Nov 22, 2015 · 6 comments
Assignees

Comments

@bep
Copy link
Member

bep commented Nov 22, 2015

Not reported in regular hugo. Looks like a Go stdlib issue:

go test -race ./...

WARNING: DATA RACE
Write by goroutine 27:
  runtime.mapassign1()
      /private/var/folders/q8/bf_4b1ts2zj0l7b0p1dv36lr0000gp/T/workdir/go/src/runtime/hashmap.go:411 +0x0
  text/template.(*Template).associate()
      /usr/local/go/src/text/template/template.go:229 +0x4c7
  text/template.(*Template).AddParseTree()
      /usr/local/go/src/text/template/template.go:130 +0x2b9
  text/template.(*Template).Parse()
      /usr/local/go/src/text/template/template.go:202 +0x589
  html/template.(*Template).Parse()
      /usr/local/go/src/html/template/template.go:158 +0x11b
  github.com/spf13/hugo/hugolib.pageRenderer()
      /Users/bep/go/src/github.com/spf13/hugo/hugolib/site.go:943 +0x229

Previous read by goroutine 26:
  runtime.mapaccess1_faststr()
      /private/var/folders/q8/bf_4b1ts2zj0l7b0p1dv36lr0000gp/T/workdir/go/src/runtime/hashmap_fast.go:179 +0x0
  html/template.(*Template).lookupAndEscapeTemplate()
      /usr/local/go/src/html/template/template.go:137 +0x75f
  html/template.(*Template).ExecuteTemplate()
      /usr/local/go/src/html/template/template.go:114 +0x5e
  github.com/spf13/hugo/tpl.(*GoHTMLTemplate).ExecuteTemplate()
      <autogenerated>:16 +0xa6
  github.com/spf13/hugo/hugolib.(*Site).renderThing()
      /Users/bep/go/src/github.com/spf13/hugo/hugolib/site.go:1521 +0x29b
  github.com/spf13/hugo/hugolib.(*Site).render()
      /Users/bep/go/src/github.com/spf13/hugo/hugolib/site.go:1496 +0x38b
  github.com/spf13/hugo/hugolib.(*Site).renderAndWritePage()
      /Users/bep/go/src/github.com/spf13/hugo/hugolib/site.go:1447 +0xee
  github.com/spf13/hugo/hugolib.pageRenderer()
      /Users/bep/go/src/github.com/spf13/hugo/hugolib/site.go:954 +0x532

@bep bep added the Bug label Nov 22, 2015
@anthonyfok
Copy link
Member

Seems a recent CircleCI build caught this data race too:

@tatsushid
Copy link
Contributor

This seems to occur at touching Template.Tree member from text/template/template.go, html/template/template.go or hugolib/shortcode.go. The last case, go test -race ./hugolib detects https://github.com/spf13/hugo/blob/master/hugolib/shortcode.go#L175 in my environment too.

@bep
Copy link
Member Author

bep commented Dec 3, 2015

@tatsushid that's not what I'm seeing, but it's template related, seems to me like it happens when execute and parse happens at the same time.

As this happens in tests only, I suggest @spf13 turn of circle ci until we find a proper fix. I don't want to throw "locks everywhere" until we know more.

@moorereason
Copy link
Contributor

The problem is hugolib/site.go#L958, not the stdlib:

_, err := s.Tmpl.New(self).Parse(string(p.Content))

It looks to me like s.Tmpl is a single template hanging off of Site that we have multiple goroutines trying to write to (Parse on L958) and read from (Execute via L969) during page rendering.

The race detector has detected a race on this line since goroutines were added by @spf13 back in May with 3dfb475. That line went unchanged when goroutines were added.

One odd bit of trivia as an aside:
I can only get the race detector to complain when running tests. If I use go run -race main.go server -s docs or go build -race && ./hugo server -s docs, I can't get it to error out. I must be doing something wrong.

@bep
Copy link
Member Author

bep commented Dec 17, 2015

I can only get the race detector to complain when running tests. If I use go run -race main.go server -s docs or go build -race && ./hugo server -s docs, I can't get it to error out. I must be doing something wrong.

The code path that fails is executed in tests with some synthetic test data not possible in real life (me thinks), with some Page.IsRenderable flag = false that not even the original committer remembers why he put there ...

No one have come up with a explanation of that code, so I'm gonna remove it ... or fix it ... like today if someone not complains.

@bep bep changed the title One data race in tests Some data races in tests Dec 18, 2015
bep added a commit that referenced this issue Dec 18, 2015
bep added a commit to bep/hugo that referenced this issue Dec 18, 2015
@bep bep closed this as completed in 8cea428 Dec 18, 2015
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
bep added a commit that referenced this issue Dec 13, 2021
4eb10c1a9 Set a sensible maxAge on the image cache
2c37f4f89 Update lists.md
8690c018f Update introduction.md
0458c3d88 Update index.md
150982f5e Update index.md
50dc0b6b9 Update multilingual.md
648598090 Configure image cache to use :cacheDir/images
4dfb523c3 Update introduction.md
b94d42e6f Add text to social images
d3253d2aa Add resources/_gen/images/ to .gitignore
8a56e1dfd Delete resources/_gen/images
1521e79b6 Update introduction.md
c7110a597 Update introduction.md
f7c4d220f Update introduction.md
c14ecf1ff Update introduction.md
c4b388c20 Fix shortcode in hugo-pipes/introduction (#1605)
d9876bd68 Update introduction.md
a39a532d5 Update introduction.md
fa8758122 netlify: Hugo 0.90.1
50cc40570 Update Contribute to Hugo Development
fc98fc82c Add .vscode dir to .gitignore (#1602)
8f8bcdefc Add frontmatter param to code-toggle shortcode (#1601)
f3b432c7c Add markdownlint configuration file (#1597)
7ea3aea92 netlify: Bump to 0.90.0
e2b6f990b docs: Regenerate docs helper
c02259e33 Merge commit '8d9511a08f14260cbfb73119e4afae50e5a9966d'
2e3573899 Add custom font support to images.Text
3186e6458 images: Text filter that draws text with the given options (#9239)
424f219eb tpl/transform: Optional options for highlight func
7993f17d0 Implement XML data support
1eb9d34cf Make resources.Get use a file cache for remote resources
8a0fffd56 Add remote support to resources.Get

git-subtree-dir: docs
git-subtree-split: 4eb10c1a9689aebf652011a6260a14bf8a3dcef4
@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 Apr 10, 2022
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