Skip to content

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

@jmhodges

Description

@jmhodges

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions