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

github.com/golang/protobuf version for generated files #3187

Closed
crazy-max opened this issue Oct 17, 2022 · 3 comments · Fixed by #3236
Closed

github.com/golang/protobuf version for generated files #3187

crazy-max opened this issue Oct 17, 2022 · 3 comments · Fixed by #3236

Comments

@crazy-max
Copy link
Member

github.com/golang/protobuf used to generate proto (1.3.5) is desynced with one from go.mod (1.5.2):

ARG PROTOBUF_VERSION=v1.3.5
RUN --mount=target=/root/.cache,type=cache GO111MODULE=on go install \
github.com/golang/protobuf/protoc-gen-go@${PROTOBUF_VERSION}

github.com/golang/protobuf v1.5.2

We should fix this and also inferred go install from go.mod using tools build constraint to avoid that in the future.

@crazy-max crazy-max changed the title github.com/golang/protobuf version desync for generated files github.com/golang/protobuf version for generated files Oct 17, 2022
@crazy-max
Copy link
Member Author

When using 1.5.2 in generated-files there is a diff for stack package:

---
 util/stack/stack.pb.go | 307 ++++++++++++++++++++++++++---------------
 1 file changed, 198 insertions(+), 109 deletions(-)

diff --git a/util/stack/stack.pb.go b/util/stack/stack.pb.go
index df55582db..e7a789753 100644
--- a/util/stack/stack.pb.go
+++ b/util/stack/stack.pb.go
@@ -1,172 +1,261 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.27.1
+// 	protoc        v3.11.4
 // source: stack.proto
 
 package stack
 
 import (
-	fmt "fmt"
-	proto "github.com/golang/protobuf/proto"
-	math "math"
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
 
 type Stack struct {
-	Frames               []*Frame `protobuf:"bytes,1,rep,name=frames,proto3" json:"frames,omitempty"`
-	Cmdline              []string `protobuf:"bytes,2,rep,name=cmdline,proto3" json:"cmdline,omitempty"`
-	Pid                  int32    `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"`
-	Version              string   `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"`
-	Revision             string   `protobuf:"bytes,5,opt,name=revision,proto3" json:"revision,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *Stack) Reset()         { *m = Stack{} }
-func (m *Stack) String() string { return proto.CompactTextString(m) }
-func (*Stack) ProtoMessage()    {}
-func (*Stack) Descriptor() ([]byte, []int) {
-	return fileDescriptor_b44c07feb2ca0a5a, []int{0}
-}
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
 
-func (m *Stack) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_Stack.Unmarshal(m, b)
+	Frames   []*Frame `protobuf:"bytes,1,rep,name=frames,proto3" json:"frames,omitempty"`
+	Cmdline  []string `protobuf:"bytes,2,rep,name=cmdline,proto3" json:"cmdline,omitempty"`
+	Pid      int32    `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"`
+	Version  string   `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"`
+	Revision string   `protobuf:"bytes,5,opt,name=revision,proto3" json:"revision,omitempty"`
 }
-func (m *Stack) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_Stack.Marshal(b, m, deterministic)
-}
-func (m *Stack) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_Stack.Merge(m, src)
+
+func (x *Stack) Reset() {
+	*x = Stack{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_stack_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
 }
-func (m *Stack) XXX_Size() int {
-	return xxx_messageInfo_Stack.Size(m)
+
+func (x *Stack) String() string {
+	return protoimpl.X.MessageStringOf(x)
 }
-func (m *Stack) XXX_DiscardUnknown() {
-	xxx_messageInfo_Stack.DiscardUnknown(m)
+
+func (*Stack) ProtoMessage() {}
+
+func (x *Stack) ProtoReflect() protoreflect.Message {
+	mi := &file_stack_proto_msgTypes[0]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
 }
 
-var xxx_messageInfo_Stack proto.InternalMessageInfo
+// Deprecated: Use Stack.ProtoReflect.Descriptor instead.
+func (*Stack) Descriptor() ([]byte, []int) {
+	return file_stack_proto_rawDescGZIP(), []int{0}
+}
 
-func (m *Stack) GetFrames() []*Frame {
-	if m != nil {
-		return m.Frames
+func (x *Stack) GetFrames() []*Frame {
+	if x != nil {
+		return x.Frames
 	}
 	return nil
 }
 
-func (m *Stack) GetCmdline() []string {
-	if m != nil {
-		return m.Cmdline
+func (x *Stack) GetCmdline() []string {
+	if x != nil {
+		return x.Cmdline
 	}
 	return nil
 }
 
-func (m *Stack) GetPid() int32 {
-	if m != nil {
-		return m.Pid
+func (x *Stack) GetPid() int32 {
+	if x != nil {
+		return x.Pid
 	}
 	return 0
 }
 
-func (m *Stack) GetVersion() string {
-	if m != nil {
-		return m.Version
+func (x *Stack) GetVersion() string {
+	if x != nil {
+		return x.Version
 	}
 	return ""
 }
 
-func (m *Stack) GetRevision() string {
-	if m != nil {
-		return m.Revision
+func (x *Stack) GetRevision() string {
+	if x != nil {
+		return x.Revision
 	}
 	return ""
 }
 
 type Frame struct {
-	Name                 string   `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
-	File                 string   `protobuf:"bytes,2,opt,name=File,proto3" json:"File,omitempty"`
-	Line                 int32    `protobuf:"varint,3,opt,name=Line,proto3" json:"Line,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
 
-func (m *Frame) Reset()         { *m = Frame{} }
-func (m *Frame) String() string { return proto.CompactTextString(m) }
-func (*Frame) ProtoMessage()    {}
-func (*Frame) Descriptor() ([]byte, []int) {
-	return fileDescriptor_b44c07feb2ca0a5a, []int{1}
+	Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
+	File string `protobuf:"bytes,2,opt,name=File,proto3" json:"File,omitempty"`
+	Line int32  `protobuf:"varint,3,opt,name=Line,proto3" json:"Line,omitempty"`
 }
 
-func (m *Frame) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_Frame.Unmarshal(m, b)
-}
-func (m *Frame) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_Frame.Marshal(b, m, deterministic)
-}
-func (m *Frame) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_Frame.Merge(m, src)
+func (x *Frame) Reset() {
+	*x = Frame{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_stack_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
 }
-func (m *Frame) XXX_Size() int {
-	return xxx_messageInfo_Frame.Size(m)
+
+func (x *Frame) String() string {
+	return protoimpl.X.MessageStringOf(x)
 }
-func (m *Frame) XXX_DiscardUnknown() {
-	xxx_messageInfo_Frame.DiscardUnknown(m)
+
+func (*Frame) ProtoMessage() {}
+
+func (x *Frame) ProtoReflect() protoreflect.Message {
+	mi := &file_stack_proto_msgTypes[1]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
 }
 
-var xxx_messageInfo_Frame proto.InternalMessageInfo
+// Deprecated: Use Frame.ProtoReflect.Descriptor instead.
+func (*Frame) Descriptor() ([]byte, []int) {
+	return file_stack_proto_rawDescGZIP(), []int{1}
+}
 
-func (m *Frame) GetName() string {
-	if m != nil {
-		return m.Name
+func (x *Frame) GetName() string {
+	if x != nil {
+		return x.Name
 	}
 	return ""
 }
 
-func (m *Frame) GetFile() string {
-	if m != nil {
-		return m.File
+func (x *Frame) GetFile() string {
+	if x != nil {
+		return x.File
 	}
 	return ""
 }
 
-func (m *Frame) GetLine() int32 {
-	if m != nil {
-		return m.Line
+func (x *Frame) GetLine() int32 {
+	if x != nil {
+		return x.Line
 	}
 	return 0
 }
 
-func init() {
-	proto.RegisterType((*Stack)(nil), "stack.Stack")
-	proto.RegisterType((*Frame)(nil), "stack.Frame")
+var File_stack_proto protoreflect.FileDescriptor
+
+var file_stack_proto_rawDesc = []byte{
+	0x0a, 0x0b, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x73,
+	0x74, 0x61, 0x63, 0x6b, 0x22, 0x8f, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x24,
+	0x0a, 0x06, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c,
+	0x2e, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x06, 0x66, 0x72,
+	0x61, 0x6d, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6d, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x18,
+	0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6d, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x10,
+	0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x70, 0x69, 0x64,
+	0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65,
+	0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65,
+	0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x43, 0x0a, 0x05, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12,
+	0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e,
+	0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x4c, 0x69, 0x6e, 0x65, 0x18,
+	0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x4c, 0x69, 0x6e, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f,
+	0x74, 0x6f, 0x33,
+}
+
+var (
+	file_stack_proto_rawDescOnce sync.Once
+	file_stack_proto_rawDescData = file_stack_proto_rawDesc
+)
+
+func file_stack_proto_rawDescGZIP() []byte {
+	file_stack_proto_rawDescOnce.Do(func() {
+		file_stack_proto_rawDescData = protoimpl.X.CompressGZIP(file_stack_proto_rawDescData)
+	})
+	return file_stack_proto_rawDescData
 }
 
-func init() {
-	proto.RegisterFile("stack.proto", fileDescriptor_b44c07feb2ca0a5a)
+var file_stack_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_stack_proto_goTypes = []interface{}{
+	(*Stack)(nil), // 0: stack.Stack
+	(*Frame)(nil), // 1: stack.Frame
+}
+var file_stack_proto_depIdxs = []int32{
+	1, // 0: stack.Stack.frames:type_name -> stack.Frame
+	1, // [1:1] is the sub-list for method output_type
+	1, // [1:1] is the sub-list for method input_type
+	1, // [1:1] is the sub-list for extension type_name
+	1, // [1:1] is the sub-list for extension extendee
+	0, // [0:1] is the sub-list for field type_name
 }
 
-var fileDescriptor_b44c07feb2ca0a5a = []byte{
-	// 185 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x8f, 0x3d, 0xce, 0x82, 0x40,
-	0x10, 0x86, 0xb3, 0xdf, 0xb2, 0x7c, 0x3a, 0x58, 0x98, 0xa9, 0x36, 0x56, 0x1b, 0x62, 0x41, 0x45,
-	0xa1, 0x47, 0x30, 0xa1, 0x32, 0x16, 0x78, 0x02, 0x84, 0x35, 0xd9, 0xc8, 0x5f, 0x76, 0x09, 0xd7,
-	0xf0, 0xca, 0x66, 0x06, 0xb4, 0x7b, 0xde, 0x9f, 0xe4, 0x9d, 0x81, 0x24, 0x4c, 0x55, 0xfd, 0xca,
-	0x47, 0x3f, 0x4c, 0x03, 0x2a, 0x16, 0xe9, 0x5b, 0x80, 0xba, 0x13, 0xe1, 0x11, 0xe2, 0xa7, 0xaf,
-	0x3a, 0x1b, 0xb4, 0x30, 0x32, 0x4b, 0x4e, 0xbb, 0x7c, 0xa9, 0x17, 0x64, 0x96, 0x6b, 0x86, 0x1a,
-	0xfe, 0xeb, 0xae, 0x69, 0x5d, 0x6f, 0xf5, 0x9f, 0x91, 0xd9, 0xb6, 0xfc, 0x4a, 0xdc, 0x83, 0x1c,
-	0x5d, 0xa3, 0xa5, 0x11, 0x99, 0x2a, 0x09, 0xa9, 0x3b, 0x5b, 0x1f, 0xdc, 0xd0, 0xeb, 0xc8, 0x08,
-	0xea, 0xae, 0x12, 0x0f, 0xb0, 0xf1, 0x76, 0x76, 0x1c, 0x29, 0x8e, 0x7e, 0x3a, 0xbd, 0x80, 0xe2,
-	0x49, 0x44, 0x88, 0x6e, 0x55, 0x67, 0xb5, 0xe0, 0x02, 0x33, 0x79, 0x85, 0x6b, 0x69, 0x9b, 0x3d,
-	0x62, 0xf2, 0xae, 0x74, 0xcf, 0xb2, 0xcc, 0xfc, 0x88, 0xf9, 0xc9, 0xf3, 0x27, 0x00, 0x00, 0xff,
-	0xff, 0xfd, 0x2c, 0xbb, 0xfb, 0xf3, 0x00, 0x00, 0x00,
+func init() { file_stack_proto_init() }
+func file_stack_proto_init() {
+	if File_stack_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_stack_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Stack); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_stack_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Frame); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+	}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: file_stack_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   2,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_stack_proto_goTypes,
+		DependencyIndexes: file_stack_proto_depIdxs,
+		MessageInfos:      file_stack_proto_msgTypes,
+	}.Build()
+	File_stack_proto = out.File
+	file_stack_proto_rawDesc = nil
+	file_stack_proto_goTypes = nil
+	file_stack_proto_depIdxs = nil
 }

This leads to lint issues:

 #13 104.8 util/stack/stack.go:82:24: copylocks: Wrap passes lock by value: github.com/moby/buildkit/util/stack.Stack contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (govet)
#13 104.8 func Wrap(err error, s Stack) error {
#13 104.8                        ^
#13 104.8 util/stack/stack.go:83:27: copylocks: literal copies lock value from s: github.com/moby/buildkit/util/stack.Stack contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (govet)
#13 104.8 	return &withStack{stack: s, error: err}
#13 104.8 	                         ^
#13 104.8 util/grpcerrors/grpcerrors.go:184:26: copylocks: call of stack.Wrap copies lock value: github.com/moby/buildkit/util/stack.Stack contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex (govet)
#13 104.8 			err = stack.Wrap(err, *s)

@thaJeztah
Copy link
Member

Note that;

We should probably update that dependency to v1.0.4 to prevent go modules accidentally pulling in v1.0.3

@crazy-max
Copy link
Member Author

We track this one in #3119

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

Successfully merging a pull request may close this issue.

2 participants