Protoc crashes on a dotted option that leaves required fields unset
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C++
- スター
- 72.2k
- フォーク
- 16.4k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 342
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
protocolbuffers/protobuf のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
protocolbuffers/protobuf#31768 ·
メンテナーはふだん 1 日以内に返信
-
feature request packaging & distribution python
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
protocolbuffers/protobuf#31654 ·
メンテナーはふだん 1 日以内に返信
-
google-protobuf 0.36.2-release fails to compile for ARMv7: @progbits rejected in global_asm!対応中かも @farisbasha が 2 日前に担当しました。 オープンbug help wanted rust
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
protocolbuffers/protobuf#31619 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Null pointer passed to memcpy in lupb_decode() when the second argument is nil対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug help wanted lua
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
protocolbuffers/protobuf#31392 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
protocolbuffers/protobuf#31032 ·
メンテナーはふだん 1 日以内に返信
protocolbuffers/protobuf の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 7 日以内に返信
-
bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
microsoft/DirectXShaderCompiler#9155 ·
メンテナーはふだん 2 日以内に返信
-
Errors in 1.20 proseオープンCampaign DiD Campaign EI Campaign HttT Campaign TDG Campaign TSG Campaign WoF Enhancement Help Prose Stable 1.20
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
wesnoth/wesnoth#11749 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信