Decoding a message-valued oneof arm after a scalar arm crashes
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
The crash happens in hyperpb's decoding of a message-valued oneof arm after a scalar arm, reproduced by the Go program in the issue body that builds an Envelope descriptor with a scalar and a nested Child arm and calls message.Unmarshal. Start by running that reproducer, then read the unmarshal path in the hyperpb package to see how oneof arms are tracked when a later field replaces an earlier one. Done means the reproducer returns nested with nested.value == 9 and the scalar arm is cleared, with a regression test added.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Unmarshalling a payload with two different arms of the same oneof crashes when the first arm is scalar and the later arm is a message. Protobuf permits this wire input. The last arm should be active.
Versions / platform
buf.build/go/hyperpbv0.1.3google.golang.org/protobufv1.36.9- Go 1.27.4 on
darwin/arm64
Reproducer
Save as main.go in an empty directory and run:
go mod init repro
go get buf.build/go/[email protected] google.golang.org/[email protected]
go run .
package main
import (
"buf.build/go/hyperpb"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/types/descriptorpb"
)
func main() {
file := &descriptorpb.FileDescriptorProto{
Name: proto.String("repro.proto"),
Package: proto.String("repro"),
Syntax: proto.String("proto3"),
MessageType: []*descriptorpb.DescriptorProto{
{
Name: proto.String("Child"),
Field: []*descriptorpb.FieldDescriptorProto{{
Name: proto.String("value"), Number: proto.Int32(1),
Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(),
}},
},
{
Name: proto.String("Envelope"),
OneofDecl: []*descriptorpb.OneofDescriptorProto{{Name: proto.String("choice")}},
Field: []*descriptorpb.FieldDescriptorProto{
{Name: proto.String("scalar"), Number: proto.Int32(1), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), OneofIndex: proto.Int32(0)},
{Name: proto.String("nested"), Number: proto.Int32(2), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".repro.Child"), OneofIndex: proto.Int32(0)},
},
},
},
}
descriptor, err := protodesc.NewFile(file, nil)
check(err)
envelope := descriptor.Messages().ByName("Envelope")
// scalar = 1 followed by nested { value: 9 }
var payload []byte
payload = protowire.AppendTag(payload, 1, protowire.VarintType)
payload = protowire.AppendVarint(payload, 1)
payload = protowire.AppendTag(payload, 2, protowire.BytesType)
payload = protowire.AppendBytes(payload, []byte{8, 9})
shared := new(hyperpb.Shared)
defer shared.Free()
message := shared.NewMessage(hyperpb.CompileMessageDescriptor(envelope))
check(message.Unmarshal(payload))
}
func check(err error) {
if err != nil {
panic(err)
}
}
Observed
go run . panics with runtime error: invalid memory address or nil pointer dereference while decoding the message arm.
Expected
Decoding succeeds with nested as the active arm and nested.value == 9. That value comes from the later message arm. The earlier scalar arm is discarded.
- Ngôn ngữ chính
- Go
- Star
- 691
- Fork
- 19
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bufbuild/hyperpb-go
-
# Decoding a message-valued map entry with an omitted value failsCó thể đã có người làm @MaxWang007 đã nhận 6 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
bufbuild/hyperpb-go#50 ·
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 45/100
bufbuild/hyperpb-go#49 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
bufbuild/hyperpb-go#30 · 1 bình luận · 1 reaction ·
Tất cả issue của bufbuild/hyperpb-go
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster no-stale P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openclaw/crabbox#3249 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
ec2-subnet, security-group and internet-gateway skip all resources when one is deleted during the scanCó thể đã có người làm @toabctl đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
gruntwork-io/cloud-nuke#1208 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
snowflakedb/gosnowflake#1872 ·