Skip to content

v1.15.1

Compare
Choose a tag to compare
@jhump jhump released this 04 Mar 01:39
81aa758

This is small bugfix release to address regressions reported in v1.15.0.

It also fixes a panic bug that can occur when a program includes both the grpcreflect package from this module and v1.52.0 or newer of the "google.golang.org/grpc" module.

"github.com/jhump/protoreflect/desc/protoparse"

Changes/fixes:

  • As of v1.15.0, descriptors returned from this package would include dynamic extension fields to represent option values for custom options that were defined in the set of files being compiled. This was a regression from all previous versions, where custom options were represented using statically known extension fields (i.e. extensions that were generated to Go code and linked into the calling program) or as unrecognized fields. This breaks some usages, where calling code is using type assertions of the extension value to a generated struct (which fails when the value is a dynamic message value). This has been fixed, and the behavior from v1.14.1 and before has been restored.
  • As of v1.15.0, a data race was possible. This is was a regression, where #236 revealed its ugly head again. The issue would occur if a parse operation used the Parser.LookupImport or Parser.LookupImportProto field to supply some dependencies as descriptors instead of as source. The race occurred when the same descriptor was referenced from different, concurrent parse operations: one goroutine would modify the descriptor during linking, while another goroutine was trying to access it (without synchronization). It has now been fixed (via a fix in the underlying protocompile library: bufbuild/protocompile#103).

"github.com/jhump/protoreflect/grpcreflect"

Changes/fixes:

  • This package includes its own internal copy of generated Go code corresponding to grpc/reflection/v1/reflection.proto. This was because, historically, there were no released Go packages that included it. But as of v1.52.0 of the grpc-go runtime, another package now provides this. If both packages are linked into the same program, a panic will occur during program initialization due to there being multiple, conflicting definitions of these types. As of v1.57.0 of grpc-go, this init-time panic is guaranteed to happen. This panic is resolved in this version (the internal copy is now registered using a non-conflicting name). An example panic stack-trace follows:
    panic: proto: file "reflection.proto" has a name conflict over grpc.reflection.v1.ErrorResponse
    	previously from: "google.golang.org/grpc/reflection/grpc_reflection_v1"
    	currently from:  "github.com/jhump/protoreflect/grpcreflect/internal/grpc_reflection_v1"
    See https://protobuf.dev/reference/go/faq#namespace-conflict
    
    goroutine 1 [running]:
    google.golang.org/protobuf/reflect/protoregistry.glob..func1({0x1075580e0?, 0xc0005e2800?}, {0x1075580e0?, 0xc0005e2840})
            /.../go/pkg/mod/google.golang.org/protobuf@v1.31.0/reflect/protoregistry/registry.go:56 +0x264
    google.golang.org/protobuf/reflect/protoregistry.(*Files).RegisterFile.func1({0x107569940, 0xc0006fc5b0})
            /.../go/pkg/mod/google.golang.org/protobuf@v1.31.0/reflect/protoregistry/registry.go:154 +0x2ec
    google.golang.org/protobuf/reflect/protoregistry.rangeTopLevelDescriptors({0x10756d6c8, 0xc0004e76c0}, 0xc00071ce28)
            /.../go/pkg/mod/google.golang.org/protobuf@v1.31.0/reflect/protoregistry/registry.go:417 +0x148
    google.golang.org/protobuf/reflect/protoregistry.(*Files).RegisterFile(0xc0005ce258, {0x10756d6c8?, 0xc0004e76c0?})
            /.../go/pkg/mod/google.golang.org/protobuf@v1.31.0/reflect/protoregistry/registry.go:149 +0x708
    google.golang.org/protobuf/internal/filedesc.Builder.Build({{0x1072414ee, 0x45}, {0x108070e00, 0x6bd, 0x6bd}, 0x0, 0x8, 0x0, 0x1, {0x10755ec98, ...}, ...})
            /.../go/pkg/mod/google.golang.org/protobuf@v1.31.0/internal/filedesc/build.go:112 +0x22c
    google.golang.org/protobuf/internal/filetype.Builder.Build({{{0x1072414ee, 0x45}, {0x108070e00, 0x6bd, 0x6bd}, 0x0, 0x8, 0x0, 0x1, {0x0, ...}, ...}, ...})
            /.../go/pkg/mod/google.golang.org/protobuf@v1.31.0/internal/filetype/build.go:138 +0x22c
    github.com/jhump/protoreflect/grpcreflect/internal/grpc_reflection_v1.file_reflection_proto_init()
            /.../go/pkg/mod/github.com/jhump/protoreflect@v1.14.0/grpcreflect/internal/grpc_reflection_v1/reflection.pb.go:947 +0x558
    github.com/jhump/protoreflect/grpcreflect/internal/grpc_reflection_v1.init.0()
            /.../go/pkg/mod/github.com/jhump/protoreflect@v1.14.0/grpcreflect/internal/grpc_reflection_v1/reflection.pb.go:818 +0x24