Skip to content
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

OpenAPIv2.go and OpenAPIv3.go both copy mutexes, generating racy code #9

Open
jmhodges opened this issue Dec 20, 2023 · 0 comments
Open

Comments

@jmhodges
Copy link

It seems like the openapiv2 and openapiv3 codebases include generated code that violates the Go copylock code analysis. (That code analysis checks to make sure that sync.Mutex is used with a pointer and isn't copied by value, rendering it unable to protect data.)

That code seems to be generated, so it might be a bug in the generator (I believe protoc-gen-go includes those sync.Mutex's explicitly to keep MessageState from being copied like this).

The errors look like:

openapiv2/OpenAPIv2.go:5872:10: assignment copies lock value to *m: github.com/google/gnostic-models/openapiv2.JsonReference contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (copylocks)
openapiv2/OpenAPIv2.go:6248:11: assignment copies lock value to *m: github.com/google/gnostic-models/openapiv2.ParametersItem contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (copylocks)
openapiv2/OpenAPIv2.go:6268:10: assignment copies lock value to *m: github.com/google/gnostic-models/openapiv2.PathItem contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (copylocks)
openapiv2/OpenAPIv2.go:6542:11: assignment copies lock value to *m: github.com/google/gnostic-models/openapiv2.ResponseValue contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (copylocks)
openapiv2/OpenAPIv2.go:6584:10: assignment copies lock value to *m: github.com/google/gnostic-models/openapiv2.Schema contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (copylocks)

and

openapiv3/OpenAPIv3.go:6085:10: assignment copies lock value to *m: github.com/google/gnostic-models/openapiv3.PathItem contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (copylocks)
openapiv3/OpenAPIv3.go:6213:10: assignment copies lock value to *m: github.com/google/gnostic-models/openapiv3.Reference contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (copylocks)
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

No branches or pull requests

1 participant