Skip to content

text/template: data race on lexer.pos #3886

@dvyukov

Description

@dvyukov
ThreadSanitizer says:

WARNING: DATA RACE
Write by goroutine 2:
  text/template/parse.(*lexer).next()
      src/pkg/text/template/parse/lex.go:140 +0x111
  text/template/parse.lexInsideAction()
      src/pkg/text/template/parse/lex.go:293 +0x144
  text/template/parse.(*lexer).run()
      src/pkg/text/template/parse/lex.go:223 +0x65
Previous read by goroutine 0:
  text/template/parse.(*lexer).lineNumber()
      src/pkg/text/template/parse/lex.go:186 +0x50
  text/template/parse.(*Tree).action()
      src/pkg/text/template/parse/parse.go:317 +0x151
  text/template/parse.(*Tree).textOrAction()
      src/pkg/text/template/parse/parse.go:288 +0x69
  text/template/parse.(*Tree).itemList()
      src/pkg/text/template/parse/parse.go:270 +0xbc
  text/template/parse.(*Tree).parseControl()
      src/pkg/text/template/parse/parse.go:373 +0xfd
  text/template/parse.(*Tree).ifControl()
      src/pkg/text/template/parse/parse.go:391 +0x3a
  text/template/parse.(*Tree).action()
      src/pkg/text/template/parse/parse.go:307 +0xed
  text/template/parse.(*Tree).textOrAction()
      src/pkg/text/template/parse/parse.go:288 +0x69
  text/template/parse.(*Tree).parse()
      src/pkg/text/template/parse/parse.go:234 +0x408
  text/template/parse.(*Tree).Parse()
      src/pkg/text/template/parse/parse.go:175 +0x280
  text/template/parse.Parse()
      src/pkg/text/template/parse/parse.go:37 +0x12d
  text/template.(*Template).Parse()
      src/pkg/text/template/template.go:168 +0x29c
  cmd/go.init()
      src/cmd/go/tag_test.go:-1137 +0x190a
  main.init()
      _testmain.go:20 +0x84
  runtime.main()
      src/pkg/runtime/proc.c:237 +0x70
Goroutine 2 (running) created at:
  text/template/parse.lex()
      src/pkg/text/template/parse/lex.go:216 +0x215
  text/template/parse.(*Tree).Parse()
      src/pkg/text/template/parse/parse.go:174 +0xf4
  text/template/parse.Parse()
      src/pkg/text/template/parse/parse.go:37 +0x12d
  text/template.(*Template).Parse()
      src/pkg/text/template/template.go:168 +0x29c
  cmd/go.init()
      src/cmd/go/tag_test.go:-1137 +0x190a
  main.init()
      _testmain.go:20 +0x84
  runtime.main()
      src/pkg/runtime/proc.c:237 +0x70

Similar reports on cmd/go, text/template, text/template/parse, html/template,
net/rpc/jsonrpc.

Total Undefined Behavior under gccgo aside, at least it leads to non-deterministic error
messages, it can contain either the correct line or any arbitrary subsequent line.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions