Skip to content

fix DATA RACE when it calls nextIndex()#5

Open
t2y wants to merge 1 commit intoake-persson:masterfrom
t2y:fix-rade-condition
Open

fix DATA RACE when it calls nextIndex()#5
t2y wants to merge 1 commit intoake-persson:masterfrom
t2y:fix-rade-condition

Conversation

@t2y
Copy link
Copy Markdown

@t2y t2y commented Mar 8, 2024

I found a DATA RACE error when I wrote some test code using mapslice-json.

You can reproduce quickly by invoking a test function included in this PR.

$ go test -race ./.... -run TestConcurrentUnmarshal
==================
WARNING: DATA RACE
Read at 0x0000007e6a28 by goroutine 10:
  github.com/ake-persson/mapslice-json.nextIndex()
      path/to/mapslice-json/mapslice.go:26 +0x127
  github.com/ake-persson/mapslice-json.(*MapItem).UnmarshalJSON()
      path/to/mapslice-json/mapslice.go:76 +0x113
  encoding/json.(*decodeState).literalStore()
      /usr/local/go1.22.0/src/encoding/json/decode.go:854 +0x394a
...

Also, I updated go version and MakeFile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant