Skip to content

text/template: data race in funcs #9945

@bep

Description

@bep

As reported by Go's race detector when building Hugo (https://github.com/spf13/hugo) with go build -race and then using Hugo to build a site:

==================
WARNING: DATA RACE
Write by goroutine 56:
  runtime.mapassign1()
      /home/bep/.gvm/gos/go1.4.2/src/runtime/hashmap.go:383 +0x0
  text/template.addValueFuncs()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/funcs.go:68 +0x4bd
  text/template.(*Template).Funcs()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/template.go:148 +0x253
  html/template.(*escaper).commit()
      /home/bep/.gvm/gos/go1.4.2/src/html/template/escape.go:741 +0x121
  html/template.escapeTemplate()
      /home/bep/.gvm/gos/go1.4.2/src/html/template/escape.go:39 +0x630
  html/template.(*Template).escape()
      /home/bep/.gvm/gos/go1.4.2/src/html/template/template.go:59 +0x1b5
  html/template.(*Template).Execute()
      /home/bep/.gvm/gos/go1.4.2/src/html/template/template.go:75 +0x4d
  github.com/spf13/hugo/hugolib.ShortcodeRender()
      /home/bep/dev/go/src/github.com/spf13/hugo/hugolib/shortcode.go:486 +0xf8
  ...

Previous read by goroutine 58:
  runtime.mapaccess1_faststr()
      /home/bep/.gvm/gos/go1.4.2/src/runtime/hashmap_fast.go:179 +0x0
  text/template.findFunction()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/funcs.go:95 +0x109
  text/template.(*state).evalFunction()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:455 +0x183
  text/template.(*state).evalCommand()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:359 +0x29f
  text/template.(*state).evalPipeline()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:332 +0x207
  text/template.(*state).walk()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:167 +0x194
  text/template.(*state).walk()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:175 +0xa09
  text/template.(*state).walkIfOrWith()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:205 +0x36e
  text/template.(*state).walk()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:172 +0x75c
  text/template.(*state).walk()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:175 +0xa09
  text/template.(*state).walkIfOrWith()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:205 +0x36e
  text/template.(*state).walk()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:172 +0x75c
  text/template.(*state).walk()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:175 +0xa09
  text/template.(*Template).Execute()
      /home/bep/.gvm/gos/go1.4.2/src/text/template/exec.go:155 +0x61d
  html/template.(*Template).Execute()
      /home/bep/.gvm/gos/go1.4.2/src/html/template/template.go:78 +0xd1
 github.com/spf13/hugo/hugolib.ShortcodeRender()
      /home/bep/dev/go/src/github.com/spf13/hugo/hugolib/shortcode.go:486 +0xf8

I have tried my best to rule out the calling code as the source of this race.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions