Skip to content

gRPC plugin crashes (or fails) if the service comments contain a single $  #32171

@coryan

Description

@coryan

What version of gRPC and what language are you using?

gRPC 1.51.1, C++.

What operating system (Linux, Windows,...) and version?

Linux, Alpine Stable

What runtime / compiler are you using (e.g. python version or version of gcc)

GCC 11

What did you do?

Run the gRPC plugin over this file:

https://github.com/googleapis/googleapis/blob/master/google/cloud/certificatemanager/v1/certificate_manager.proto

At the time the file contains this comment:

https://github.com/googleapis/googleapis/blob/9fac84a6942bd3e95fca1ffe87018adbf560c514/google/cloud/certificatemanager/v1/certificate_manager.proto#L57

What did you expect to see?

A successful run.

What did you see instead?

The plugin crashes with:

[ 97%] Running gRPC C++ protocol buffer compiler on /workspace/cmake-out/external/googleapis/src/googleapis_download/google/cloud/certificatemanager/v1/certificate_manager.proto
[libprotobuf FATAL google/protobuf/io/printer.cc:142]  Unclosed variable name.
terminate called after throwing an instance of 'google::protobuf::FatalException'
  what():   Unclosed variable name.
--grpc_out: protoc-gen-grpc: Plugin killed by signal 6.

The problem seems to be in the code generator, it passes the leading comments of the service directly to the Protobuf printer:

printer->Print(service->GetLeadingComments("//").c_str());

The current Protobuf release treats single $ as a fatal error:

https://github.com/protocolbuffers/protobuf/blob/9b3231002dcfb713e619d841fc9bfa5156c211fc/src/google/protobuf/io/printer.cc#L142-L147

Anything else we should know about your project / environment?

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions