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

Stack overflow (recursive call) in 3.7.0-rc1 (Java) #5657

Closed
maja42 opened this issue Jan 31, 2019 · 1 comment
Closed

Stack overflow (recursive call) in 3.7.0-rc1 (Java) #5657

maja42 opened this issue Jan 31, 2019 · 1 comment
Assignees

Comments

@maja42
Copy link

maja42 commented Jan 31, 2019

What version of protobuf and what language are you using?
Version: 3.7.0-rc1
Language: Java

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

What did you do?
We have protobuf-files that are generated with an older version of the protobuf java compiler, namely protoc-3.5.1-linux-x86_64.
We updated the de Java-Dependency com.google.protobuf from 3.6.1 to 3.7.0-rc1.

What did you see?

The generated code for a protobuf message looks as follows:

public final Builder setUnknownFields(
    final com.google.protobuf.UnknownFieldSet unknownFields) {
    return super.setUnknownFieldsProto3(unknownFields);
}

This calls setUnknownFieldsProto3 in GeneratedMessageV3:

protected BuilderType setUnknownFieldsProto3(UnknownFieldSet unknownFields) {
    return this.setUnknownFields(unknownFields);
}

... which then calls the caller setUnknownFields, producing and endless recursion.

This did not happen with version 3.6.1, but using 3.7.0-rc1 breaks our builds:

java.lang.StackOverflowError
at com.company.app.PbAppProtos$MyMessage$Builder.$jacocoInit(PbAppProtos.java)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java)
at com.google.protobuf.GeneratedMessageV3$Builder.setUnknownFieldsProto3(GeneratedMessageV3.java:725)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java:12366)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java:11585)
at com.google.protobuf.GeneratedMessageV3$Builder.setUnknownFieldsProto3(GeneratedMessageV3.java:725)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java:12366)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java:11585)
at com.google.protobuf.GeneratedMessageV3$Builder.setUnknownFieldsProto3(GeneratedMessageV3.java:725)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java:12366)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java:11585)
at com.google.protobuf.GeneratedMessageV3$Builder.setUnknownFieldsProto3(GeneratedMessageV3.java:725)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java:12366)
at com.company.app.PbAppProtos$MyMessage$Builder.setUnknownFields(PbAppProtos.java:11585)
...

What did you expect to see

... the new rc should be compatible with older generated protobuf files or have a major version change.

@acozzette acozzette self-assigned this Jan 31, 2019
@acozzette
Copy link
Member

@maja42 Thank you for the bug report. I will make sure we get this fixed in the 3.7.0 release.

acozzette added a commit to acozzette/protobuf that referenced this issue Jan 31, 2019
…olbuffers#5657)

GeneratedMessageV3#setUnknownFieldsProto3 was trying to delegate to
setUnknownFields but was inadvertently resulting in infinite recursion.
This commit makes setUnknownFields and setUnknownFieldsProto3 delegate
to a common private method to fix the problem and avoid confusion.
acozzette added a commit that referenced this issue Feb 1, 2019
GeneratedMessageV3#setUnknownFieldsProto3 was trying to delegate to
setUnknownFields but was inadvertently resulting in infinite recursion.
This commit makes setUnknownFields and setUnknownFieldsProto3 delegate
to a common private method to fix the problem and avoid confusion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants