gobuffalo / buffalo

Rapid Web Development w/ Go
http://gobuffalo.io
MIT License
8.07k stars 573 forks source link

fatal error: concurrent map writes #303

Closed Wanderfalke closed 7 years ago

Wanderfalke commented 7 years ago

Hi! Trying to make parallel requests gives me following error (running freshly generated app with default handler):

fatal error: concurrent map writes

goroutine 3195 [running]:
runtime.throw(0x47ef322, 0x15)
    /usr/local/Cellar/go/1.8/libexec/src/runtime/panic.go:596 +0x95 fp=0xc420b81140 sp=0xc420b81120
runtime.mapassign(0x4733ee0, 0xc4208f3c80, 0xc420b81218, 0x472f440)
    /usr/local/Cellar/go/1.8/libexec/src/runtime/hashmap.go:589 +0x2a1 fp=0xc420b811e0 sp=0xc420b81140
github.com/gobuffalo/velvet.(*HelperMap).Add(0xc4208fa970, 0x47e2da1, 0x7, 0x472f440, 0xc42018f3c0, 0x420b81278, 0xc420b812d0)
    /Users/alex/workspace/go/src/github.com/gobuffalo/velvet/helper_map.go:44 +0xb1 fp=0xc420b81238 sp=0xc420b811e0
github.com/gobuffalo/velvet.(*HelperMap).AddMany(0xc4208fa970, 0xc4202eba10, 0xc4208fa960, 0x0)
    /Users/alex/workspace/go/src/github.com/gobuffalo/velvet/helper_map.go:51 +0xb7 fp=0xc420b812e0 sp=0xc420b81238
github.com/gobuffalo/velvet.BuffaloRenderer(0xc420b35080, 0x153, 0xc4201dce40, 0xc4202eba10, 0xc420b35080, 0x153, 0x0, 0x0)
    /Users/alex/workspace/go/src/github.com/gobuffalo/velvet/velvet.go:17 +0x1fe fp=0xc420b81330 sp=0xc420b812e0
github.com/gobuffalo/buffalo/render.templateRenderer.exec(0xc4208d21e0, 0x47e529f, 0x9, 0xc420180de0, 0x2, 0x2, 0x47ea999, 0x10, 0xc4201dce40, 0xc420899880, ...)
    /Users/alex/workspace/go/src/github.com/gobuffalo/buffalo/render/template.go:57 +0x3e1 fp=0xc420b814b0 sp=0xc420b81330
github.com/gobuffalo/buffalo/render.templateRenderer.Render(0xc4208d21e0, 0x47e529f, 0x9, 0xc420180de0, 0x2, 0x2, 0x4acf5e0, 0xc4206e43f0, 0xc4201dce40, 0xc4203db601, ...)
    /Users/alex/workspace/go/src/github.com/gobuffalo/buffalo/render/template.go:27 +0xa2 fp=0xc420b81578 sp=0xc420b814b0
github.com/gobuffalo/buffalo/render.(*templateRenderer).Render(0xc4202eae10, 0x4acf5e0, 0xc4206e43f0, 0xc4201dce40, 0xc4202eae40, 0x4b1dc40)
    <autogenerated>:14 +0x7d fp=0xc420b815e0 sp=0xc420b81578
github.com/gobuffalo/buffalo.(*DefaultContext).Render(0xc420972d20, 0xc8, 0x4ad57e0, 0xc4202eae10, 0x0, 0x0)

go version: go version go1.8 darwin/amd64

Wanderfalke commented 7 years ago

Same thing happens on Linux (Ubuntu 16.04) go1.8 linux/amd64.

markbates commented 7 years ago

Looks like there is a mutex missing. It's been fixed here: https://github.com/gobuffalo/velvet/commit/d97471bf5d8fd758ba0ecc7a085796b71ffc8957

Strange that the race detector, and no one else has reported this, I haven't seen it either. With that said, glad to fix it! :)

$ go get -u github.com/gobuffalo/velvet

If you're just starting a new app, might I recommend switch to https://github.com/gobuffalo/plush as your template engine. It's going to be the default in v0.8.0 which comes out next week.

Here's some more info on it:

https://blog.gobuffalo.io/introduction-to-plush-82a8a12cf98a#.37gburogm

Wanderfalke commented 7 years ago

@markbates Thanks for the answer. I'm currently evaluating buffalo as replacement for a small Rails project. Looking forward to v0.8.0.