Data race occurred in tracer/seen.go#L334
sysulq opened this issue · 3 comments
sysulq commented
Describe the bug
https://github.com/pelletier/go-toml/blob/v2/internal/tracker/seen.go#L334
WARNING: DATA RACE
Read at 0x000112443500 by goroutine 19:
github.com/pelletier/go-toml/v2/internal/tracker.(*SeenTracker).checkInlineTable()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/internal/tracker/seen.go:330 +0x3a
github.com/pelletier/go-toml/v2/internal/tracker.(*SeenTracker).checkKeyValue()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/internal/tracker/seen.go:301 +0x9d2
github.com/pelletier/go-toml/v2/internal/tracker.(*SeenTracker).CheckExpression()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/internal/tracker/seen.go:159 +0x1a4
github.com/pelletier/go-toml/v2.(*decoder).handleKeyValues()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:579 +0x20d
github.com/pelletier/go-toml/v2.(*decoder).handleTable()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:561 +0x4ae
github.com/pelletier/go-toml/v2.(*decoder).handleTable-fm()
<autogenerated>:1 +0x87
github.com/pelletier/go-toml/v2.(*decoder).handleKeyPart()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:466 +0x525
github.com/pelletier/go-toml/v2.(*decoder).handleTablePart()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:610 +0x43c
github.com/pelletier/go-toml/v2.(*decoder).handleTable()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:557 +0x3a9
github.com/pelletier/go-toml/v2.(*decoder).handleRootExpression()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:266 +0x2da
github.com/pelletier/go-toml/v2.(*decoder).fromParser()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:228 +0x144
github.com/pelletier/go-toml/v2.(*decoder).FromParser()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:213 +0x1be
github.com/pelletier/go-toml/v2.Unmarshal()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:28 +0x2e7
github.com/spf13/viper/internal/encoding/toml.Codec.Decode()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/spf13/viper@v1.18.2/internal/encoding/toml/codec.go:15 +0xb6
github.com/spf13/viper/internal/encoding/toml.(*Codec).Decode()
<autogenerated>:1 +0x1f
github.com/spf13/viper/internal/encoding.(*DecoderRegistry).Decode()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/spf13/viper@v1.18.2/internal/encoding/decoder.go:60 +0xf7
github.com/spf13/viper.(*Viper).unmarshalReader()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/spf13/viper@v1.18.2/viper.go:1806 +0x29d
github.com/spf13/viper.(*Viper).ReadInConfig()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/spf13/viper@v1.18.2/viper.go:1653 +0x32d
github.com/go-kod/kod.(*Kod).parseConfig()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/go-kod/kod@v0.6.0/kod.go:364 +0x107
github.com/go-kod/kod.newKod()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/go-kod/kod@v0.6.0/kod.go:304 +0xa2a
github.com/go-kod/kod.runner.sub()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/go-kod/kod@v0.6.0/testing.go:55 +0x117
github.com/go-kod/kod.RunTest[go.shape.interface { UniqueID(*github.com/gin-gonic/gin.Context) }]()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/go-kod/kod@v0.6.0/testing.go:41 +0x1ef
github.com/go-kod/kod-mono/tests/intergration/server.TestGinController()
/Users/pilot/workspace/github.com/go-kod/kod-mono/tests/intergration/server/gin_test.go:18 +0x125
testing.tRunner()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:1689 +0x21e
testing.(*T).Run.gowrap1()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:1742 +0x44
Previous write at 0x000112443500 by goroutine 20:
github.com/pelletier/go-toml/v2/internal/tracker.(*SeenTracker).checkInlineTable()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/internal/tracker/seen.go:331 +0x50
github.com/pelletier/go-toml/v2/internal/tracker.(*SeenTracker).checkKeyValue()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/internal/tracker/seen.go:301 +0x9d2
github.com/pelletier/go-toml/v2/internal/tracker.(*SeenTracker).CheckExpression()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/internal/tracker/seen.go:159 +0x1a4
github.com/pelletier/go-toml/v2.(*decoder).handleKeyValues()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:579 +0x20d
github.com/pelletier/go-toml/v2.(*decoder).handleTable()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:561 +0x4ae
github.com/pelletier/go-toml/v2.(*decoder).handleTable-fm()
<autogenerated>:1 +0x87
github.com/pelletier/go-toml/v2.(*decoder).handleKeyPart()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:466 +0x525
github.com/pelletier/go-toml/v2.(*decoder).handleTablePart()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:610 +0x43c
github.com/pelletier/go-toml/v2.(*decoder).handleTable()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:557 +0x3a9
github.com/pelletier/go-toml/v2.(*decoder).handleRootExpression()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:266 +0x2da
github.com/pelletier/go-toml/v2.(*decoder).fromParser()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:228 +0x144
github.com/pelletier/go-toml/v2.(*decoder).FromParser()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:213 +0x1be
github.com/pelletier/go-toml/v2.Unmarshal()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/pelletier/go-toml/v2@v2.1.0/unmarshaler.go:28 +0x2e7
github.com/spf13/viper/internal/encoding/toml.Codec.Decode()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/spf13/viper@v1.18.2/internal/encoding/toml/codec.go:15 +0xb6
github.com/spf13/viper/internal/encoding/toml.(*Codec).Decode()
<autogenerated>:1 +0x1f
github.com/spf13/viper/internal/encoding.(*DecoderRegistry).Decode()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/spf13/viper@v1.18.2/internal/encoding/decoder.go:60 +0xf7
github.com/spf13/viper.(*Viper).unmarshalReader()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/spf13/viper@v1.18.2/viper.go:1806 +0x29d
github.com/spf13/viper.(*Viper).ReadInConfig()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/spf13/viper@v1.18.2/viper.go:1653 +0x32d
github.com/go-kod/kod.(*Kod).parseConfig()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/go-kod/kod@v0.6.0/kod.go:364 +0x107
github.com/go-kod/kod.newKod()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/go-kod/kod@v0.6.0/kod.go:304 +0xa2a
github.com/go-kod/kod.runner.sub()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/go-kod/kod@v0.6.0/testing.go:55 +0x117
github.com/go-kod/kod.RunTest[go.shape.interface { UniqueId(context.Context, *github.com/go-kod/kod-mono/api/gen/go/snowflake/v1.UniqueIdRequest) (*github.com/go-kod/kod-mono/api/gen/go/snowflake/v1.UniqueIdResponse, error) }]()
/Users/pilot/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/go-kod/kod@v0.6.0/testing.go:41 +0x1ef
github.com/go-kod/kod-mono/tests/intergration/server.TestGrpcController()
/Users/pilot/workspace/github.com/go-kod/kod-mono/tests/intergration/server/grpc_test.go:16 +0x125
testing.tRunner()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:1689 +0x21e
testing.(*T).Run.gowrap1()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:1742 +0x44
Goroutine 19 (running) created at:
testing.(*T).Run()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:1742 +0x825
testing.runTests.func1()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:2161 +0x85
testing.tRunner()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:1689 +0x21e
testing.runTests()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:2159 +0x8be
testing.(*M).Run()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:2027 +0xf17
main.main()
_testmain.go:49 +0x2bd
Goroutine 20 (running) created at:
testing.(*T).Run()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:1742 +0x825
testing.runTests.func1()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:2161 +0x85
testing.tRunner()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:1689 +0x21e
testing.runTests()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:2159 +0x8be
testing.(*M).Run()
/Users/pilot/.gvm/gos/go1.22.1/src/testing/testing.go:2027 +0xf17
main.main()
_testmain.go:49 +0x2bd
To Reproduce
Expected behavior
Versions
- go-toml: latest (git sha)
- go: latest
- operating system: Macos & Linux
Additional context
Add any other context about the problem here that you think may help to diagnose.
sysulq commented
Seems like we should initial the pool as a global variable or use sync.Once to avoid data race here? I would like to send a PR to fix this data race problem, if you're interested 🙂 @pelletier
pelletier commented
Thank you for catching this! I think a global variable is the way to go. A PR would be most welcomed :)
sysulq commented
@pelletier Thanks for reply, here is the PR link: #947