Dear all,

the following code panics with: runtime error: slice bounds out of range


var testTransform = transform.Chain(norm.NFD, norm.NFC)

func main() {
for i := 0; i < 200; i++ {
go func() {
transform.String(testTransform, "nonemptystring")
}()
}
time.Sleep(time.Second)
}

The reason is transform.Chain returns a Transformer which keeps an internal 
state
while sequentially applying each transformation. When called by two 
goroutines,
this state gets corrupted.

For me, this was unexpected, as each transform by itself seems thread-safe. 
Errors
caused by this behaviour might be hard to track. I suggest changing the 
implementation
of transform.Chain.Transform to generate a new state for each call or make 
a note about
this in the docs.

Or maybe I was expecting something I should not?

I can write a thread-safe version of chain.Transform if this is the way to 
go. Please comment.

Regards

Bryan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to