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

wrong pool unmarshal slize #92

Open
zdyj3170101136 opened this issue Aug 30, 2023 · 3 comments
Open

wrong pool unmarshal slize #92

zdyj3170101136 opened this issue Aug 30, 2023 · 3 comments
Labels
question Further information is requested

Comments

@zdyj3170101136
Copy link

zdyj3170101136 commented Aug 30, 2023

wrong pool unmarshal size.

my proto file:

// protoc  --go_out=. --plugin protoc-gen-go="/Users/jie.yang05/go/bin/protoc-gen-go"  --go-vtproto_out=.  --plugin protoc-gen-go-vtproto="/Users/jie.yang05/go/bin/protoc-gen-go-vtproto"  --go-vtproto_opt=features=marshal+unmarshal+size+pool ./lineentry.proto
syntax = "proto3";

package index;

option go_package="./proto";

import "github.com/planetscale/vtprotobuf/vtproto/ext.proto";

message lineEntries {
  option (vtproto.mempool) = true; // Enable memory pooling
  repeated lineEntry lineEntries = 1;
}

message lineEntry {
  uint64 address = 1;
  uint32 line = 2;
  uint32 file = 3;
}

comand

yangjie05-mac:index jie.yang05$ protoc  --go_out=. --plugin protoc-gen-go="/Users/jie.yang05/go/bin/protoc-gen-go"  --go-vtproto_out=.  --plugin protoc-gen-go-vtproto="/Users/jie.yang05/go/bin/protoc-gen-go-vtproto"   -I /Users/jie.yang05/go/pkg/mod/github.com/planetscale/vtprotobuf\@v0.4.0/include -I ./ ./lineentry.proto

generate code:

func (m *LineEntries) ResetVT() {
	for _, mm := range m.LineEntries {
		mm.ResetVT()
	}
	m.Reset()
}

func (m *LineEntries) ReturnToVTPool() {
	if m != nil {
		m.ResetVT()
		vtprotoPool_LineEntries.Put(m)
	}
}

generate code have wrong ResetVT.

@zdyj3170101136 zdyj3170101136 changed the title where is github.com/planetscale/vtprotobuf/vtproto/ext.proto? wrong pool unmarshal slize Aug 30, 2023
@vmg
Copy link
Member

vmg commented Aug 30, 2023

Can you elaborate a little bit, please? What's wrong with the ResetVT in your generated code?

@zdyj3170101136
Copy link
Author

Can you elaborate a little bit, please? What's wrong with the ResetVT in your generated code?

it should add a line:

m.lineEntries = m.lineEntries[:0]

@vmg
Copy link
Member

vmg commented Sep 5, 2023

Oh I see what you mean. This is a known bug that was fixed in the latest release: https://github.com/planetscale/vtprotobuf/releases/tag/v0.5.0

Can you try updating vtprotobuf to see if the generated code looks correct now? Thanks!

@nockty nockty added the question Further information is requested label Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants