Protoc crashes on a dotted option that leaves required fields unset
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
The report points to option interpretation and ValidateTargetConstraints in the protoc command line interface. Start by tracing how dotted and aggregate custom option values are merged and where required fields are checked; reproduce with the three .proto examples in the issue. Done means all three cases behave consistently, and an incomplete option reports an error instead of aborting.
Written by the indexing model from the issue text.
Description
What version of protobuf and what language are you using?
Version: v36.2 (libprotoc 36.2)
Language: .proto files compiled with protoc (custom options)
What supported operating system version are you using (e.g. Linux, Windows) ?
macOS (arm64)
What supported runtime / compiler version are you using (e.g. python version, gcc version)
The prebuilt protoc 36.2 release binary.
What did you do?
A custom option whose message has required fields:
// foo.proto
syntax = "proto2";
import "google/protobuf/descriptor.proto";
message Foo {
required string a = 1;
required string b = 2;
}
extend google.protobuf.FileOptions {
optional Foo foo = 50000;
}
These three files each set the option a different way:
// dotted.proto
syntax = "proto2";
import "foo.proto";
option (foo).a = "x";
option (foo).b = "y";
// literal_then_dotted.proto
syntax = "proto2";
import "foo.proto";
option (foo) = { a: "x" };
option (foo).b = "y";
// partial.proto
syntax = "proto2";
import "foo.proto";
option (foo).a = "x";
Compiled each with protoc -I. -o /dev/null <file>.
What did you expect to see
The required-field check should be consistent. Dotted options already merge into one value. I expected required fields to be checked on that final merged value with an ordinary error:
- dotted.proto: accepted.
- literal_then_dotted.proto: accepted. The final value is
{ a: "x" b: "y" }, the same as dotted.proto. - partial.proto: a normal error such as
Option "(foo)" is missing required fields: b, with exit code 1.
What did you see instead?
- dotted.proto: accepted (exit 0).
- literal_then_dotted.proto: rejected, even though the merged value is complete:
literal_then_dotted.proto:5:16: Error while parsing option value for "foo": Message missing required fields: b
- partial.proto: protoc logs an error and then aborts on a failed CHECK (exit code 134):
E... message_lite.cc:200] Can't parse message of type "google.protobuf.FileOptions" because it is missing required fields: (foo).b
F... command_line_interface.cc:1259] Check failed: dynamic_message->ParseFromString(serialized)
*** Check failure stack trace: ***
@ ... absl::lts_20250814::log_internal::LogMessage::Flush()
@ ... google::protobuf::compiler::(anonymous namespace)::ValidateTargetConstraints()
@ ... google::protobuf::compiler::CommandLineInterface::Run()
@ ... google::protobuf::compiler::ProtobufMain()
Anything else we should know about your project / environment
Required fields are checked at two different points:
- When an aggregate ({ ... }) option value is parsed, each literal must be complete on its own, even if later options fill in the rest.
- The merged options for dotted names aren't checked during option interpretation. The first check that sees them is the ParseFromString in ValidateTargetConstraints, which hits a CHECK and aborts.
As a result, merging a literal with later dotted options behaves differently from merging dotted options with each other, and a partially set option crashes instead of reporting an error.
A single check on each element's final merged options during option interpretation would fix both.
- Dominant language
- C++
- Stars
- 72.2k
- Forks
- 16.4k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 342
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from protocolbuffers/protobuf
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
protocolbuffers/protobuf#31768 ·
Maintainers usually reply within 1 day
-
feature request packaging & distribution python
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31654 ·
Maintainers usually reply within 1 day
-
google-protobuf 0.36.2-release fails to compile for ARMv7: @progbits rejected in global_asm!Possibly taken @farisbasha claimed this 1 day ago. Openbug help wanted rust
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31619 · 3 comments ·
Maintainers usually reply within 1 day
-
Null pointer passed to memcpy in lupb_decode() when the second argument is nilPossibly taken A pull request linked to this issue is open or already merged. Openbug help wanted lua
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31392 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
protocolbuffers/protobuf#31032 ·
Maintainers usually reply within 1 day
All issues in protocolbuffers/protobuf
Similar issues
-
agent:Windows bug in progress pri:medium sev:low testing windows
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#125651 ·
Maintainers usually reply within 1 day
-
Android: with view recycling on, a recycled View keeps its nextFocusLeftPossibly taken A pull request linked to this issue is open or already merged. OpenNeeds: Triage :mag: Platform: Android
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/react-native#60167 ·
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days