-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get a data race at internalLoadPredictSizePerValue
#26
Comments
Is there any source code to reproduce this bug? And what is your OS env? I think it may indeed be a problem in 32-bit machines. |
If you are using 32-bit system, you can degraded to v1.3.3. I will fix it ASAP |
64-bit |
ARM64 MacBook? I borrowed one (Apple M1 Pro) and ran I reviewed the codes by myself, there IS a race problem for 32-bit system. I should fix it and release a new one soon. But for arm64? I think the direct access to an uint64 variable should be goroutine safe. What do you think? Am I wrong? |
no matter how, I will release a new tag to solve this protencial race problem. If you are in hurry, please downgrade to v1.3.3. |
Or you may try my latest |
I speculate, it can be atomic but it's not guaranteed. Depends on how a particular compiler and compiler configuration decided to produce a target instruction. |
Please try |
Yes, that solved it, thanks. I use this code to reproduce (with package main
import (
"fmt"
"github.com/Andrew-M-C/go.jsonvalue"
"sync"
)
func main() {
limit := 10
var wg sync.WaitGroup
wg.Add(5)
for i := 0; i < 5; i++ {
go func(j int) {
for j := 0; j < 100; j++ {
v, err := jsonvalue.Unmarshal([]byte(fmt.Sprintf(`
{
"class":"CONSTANT",
"type":"VALUE_CONSTANT",
"alias":"",
"value":{
"type":{
"id":"INTEGER",
"type_info":null
},
"is_null":false,
"value":%d
}
}
`, limit)))
if err != nil {
panic(err)
}
v.Append(nil)
}
wg.Done()
}(i)
}
wg.Wait()
} for example:
|
v1.3.5 released and officially fixed. |
when I call this
v, err := jsonvalue.Unmarshal(serialized)
The text was updated successfully, but these errors were encountered: