You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The lexer passed into startParse starts a goroutine which runs and accesses breakOK and continueOK, and potentially races with their initialization in startParse.
Before https://go-review.googlesource.com/c/go/+/410296 this issue doesn't manifest because the lexer's items channel is blocking and the lexer won't get to an identifier until the reader pulled at least one token. Once a buffer is added to the channel, however, the lexer runs ahead a bit and triggers the race.
The fix should be to remove the racing access to these fields.
The text was updated successfully, but these errors were encountered:
The downside is that it makes the initialization of lex(...) a bit verbose, with three boolean parameters. Some alternatives considered:
Create a "config" struct for lex(...) with named fields, making this intialization more readable
Separate the goroutine launch of the lexer from the lexer's creation: something like a separate start method. I don't really like this as it complicates the API and still leaves races lurking if users do things in the wrong order.
What version of Go are you using (
go version
)?tip
Issue description
Uncovered while working on https://go-review.googlesource.com/c/go/+/410296
Tree.Parse
intext/template/parse/parse.go
invokes:Where
startParse
is:The lexer passed into
startParse
starts a goroutine which runs and accessesbreakOK
andcontinueOK
, and potentially races with their initialization instartParse
.Before https://go-review.googlesource.com/c/go/+/410296 this issue doesn't manifest because the lexer's items channel is blocking and the lexer won't get to an identifier until the reader pulled at least one token. Once a buffer is added to the channel, however, the lexer runs ahead a bit and triggers the race.
The fix should be to remove the racing access to these fields.
The text was updated successfully, but these errors were encountered: