Skip to content

Commit

Permalink
Merge pull request #8329 from acozzette/merge-3-15-x
Browse files Browse the repository at this point in the history
Merge 3.15.x into master
  • Loading branch information
acozzette committed Feb 22, 2021
2 parents 5911099 + 6e84adc commit 326ea55
Show file tree
Hide file tree
Showing 36 changed files with 124 additions and 67 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,8 @@
2021-02-05 version 3.15.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)

Ruby
* Bugfix for Message.[] for repeated or map fields (#8313)

2021-02-05 version 3.15.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)

Protocol Compiler
Expand Down
2 changes: 1 addition & 1 deletion Protobuf-C++.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Protobuf-C++'
s.version = '3.15.0'
s.version = '3.15.1'
s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/protobuf'
s.license = '3-Clause BSD License'
Expand Down
2 changes: 1 addition & 1 deletion Protobuf.podspec
Expand Up @@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
s.version = '3.15.0'
s.version = '3.15.1'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = '3-Clause BSD License'
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[3.15.0],[protobuf@googlegroups.com],[protobuf])
AC_INIT([Protocol Buffers],[3.15.1],[protobuf@googlegroups.com],[protobuf])

AM_MAINTAINER_MODE([enable])

Expand Down
2 changes: 1 addition & 1 deletion csharp/Google.Protobuf.Tools.nuspec
Expand Up @@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
<version>3.15.0</version>
<version>3.15.1</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>
Expand Down
2 changes: 1 addition & 1 deletion csharp/src/Google.Protobuf/Google.Protobuf.csproj
Expand Up @@ -4,7 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.15.0</VersionPrefix>
<VersionPrefix>3.15.1</VersionPrefix>
<!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
<LangVersion>7.2</LangVersion>
<Authors>Google Inc.</Authors>
Expand Down
2 changes: 1 addition & 1 deletion java/bom/pom.xml
Expand Up @@ -4,7 +4,7 @@

<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId>
<version>3.15.0</version>
<version>3.15.1</version>
<packaging>pom</packaging>

<name>Protocol Buffers [BOM]</name>
Expand Down
2 changes: 1 addition & 1 deletion java/core/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.15.0</version>
<version>3.15.1</version>
</parent>

<artifactId>protobuf-java</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lite/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.15.0</version>
<version>3.15.1</version>
</parent>

<artifactId>protobuf-javalite</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/pom.xml
Expand Up @@ -4,7 +4,7 @@

<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.15.0</version>
<version>3.15.1</version>
<packaging>pom</packaging>

<name>Protocol Buffers [Parent]</name>
Expand Down
2 changes: 1 addition & 1 deletion java/util/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.15.0</version>
<version>3.15.1</version>
</parent>

<artifactId>protobuf-java-util</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
@@ -1,6 +1,6 @@
{
"name": "google-protobuf",
"version": "3.15.0",
"version": "3.15.1",
"description": "Protocol Buffers for JavaScript",
"main": "google-protobuf.js",
"files": [
Expand Down
23 changes: 19 additions & 4 deletions php/ext/google/protobuf/package.xml
Expand Up @@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email>
<active>yes</active>
</lead>
<date>2021-02-18</date>
<time>10:33:10</time>
<date>2021-02-19</date>
<time>10:50:04</time>
<version>
<release>3.15.0</release>
<api>3.15.0</api>
<release>3.15.1</release>
<api>3.15.1</api>
</version>
<stability>
<release>stable</release>
Expand Down Expand Up @@ -805,5 +805,20 @@ G A release.
<notes>
</notes>
</release>
<release>
<version>
<release>3.15.1</release>
<api>3.15.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2021-02-19</date>
<time>10:50:04</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>
</notes>
</release>
</changelog>
</package>
2 changes: 1 addition & 1 deletion php/ext/google/protobuf/protobuf.h
Expand Up @@ -76,7 +76,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

#define PHP_PROTOBUF_VERSION "3.15.0"
#define PHP_PROTOBUF_VERSION "3.15.1"

// ptr -> PHP object cache. This is a weak map that caches lazily-created
// wrapper objects around upb types:
Expand Down
2 changes: 1 addition & 1 deletion protoc-artifacts/pom.xml
Expand Up @@ -8,7 +8,7 @@
</parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>3.15.0</version>
<version>3.15.1</version>
<packaging>pom</packaging>
<name>Protobuf Compiler</name>
<description>
Expand Down
2 changes: 1 addition & 1 deletion python/google/protobuf/__init__.py
Expand Up @@ -30,4 +30,4 @@

# Copyright 2007 Google Inc. All Rights Reserved.

__version__ = '3.15.0'
__version__ = '3.15.1'
64 changes: 33 additions & 31 deletions ruby/ext/google/protobuf_c/message.c
Expand Up @@ -292,6 +292,35 @@ static void Message_setfield(upb_msg* msg, const upb_fielddef* f, VALUE val,
upb_msg_set(msg, f, msgval, arena);
}

static VALUE Message_getfield(VALUE _self, const upb_fielddef* f) {
Message* self = ruby_to_Message(_self);
// This is a special-case: upb_msg_mutable() for map & array are logically
// const (they will not change what is serialized) but physically
// non-const, as they do allocate a repeated field or map. The logical
// constness means it's ok to do even if the message is frozen.
upb_msg *msg = (upb_msg*)self->msg;
upb_arena *arena = Arena_get(self->arena);
if (upb_fielddef_ismap(f)) {
upb_map *map = upb_msg_mutable(msg, f, arena).map;
const upb_fielddef *key_f = map_field_key(f);
const upb_fielddef *val_f = map_field_value(f);
upb_fieldtype_t key_type = upb_fielddef_type(key_f);
TypeInfo value_type_info = TypeInfo_get(val_f);
return Map_GetRubyWrapper(map, key_type, value_type_info, self->arena);
} else if (upb_fielddef_isseq(f)) {
upb_array *arr = upb_msg_mutable(msg, f, arena).array;
return RepeatedField_GetRubyWrapper(arr, TypeInfo_get(f), self->arena);
} else if (upb_fielddef_issubmsg(f)) {
if (!upb_msg_has(self->msg, f)) return Qnil;
upb_msg *submsg = upb_msg_mutable(msg, f, arena).msg;
const upb_msgdef *m = upb_fielddef_msgsubdef(f);
return Message_GetRubyWrapper(submsg, m, self->arena);
} else {
upb_msgval msgval = upb_msg_get(self->msg, f);
return Convert_UpbToRuby(msgval, TypeInfo_get(f), self->arena);
}
}

static VALUE Message_field_accessor(VALUE _self, const upb_fielddef* f,
int accessor_type, int argc, VALUE* argv) {
upb_arena *arena = Arena_get(Message_GetArena(_self));
Expand Down Expand Up @@ -350,36 +379,11 @@ static VALUE Message_field_accessor(VALUE _self, const upb_fielddef* f,
return INT2NUM(msgval.int32_val);
}
}
case METHOD_GETTER: {
Message* self = ruby_to_Message(_self);
// This is a special-case: upb_msg_mutable() for map & array are logically
// const (they will not change what is serialized) but physically
// non-const, as they do allocate a repeated field or map. The logical
// constness means it's ok to do even if the message is frozen.
upb_msg *msg = (upb_msg*)self->msg;
if (upb_fielddef_ismap(f)) {
upb_map *map = upb_msg_mutable(msg, f, arena).map;
const upb_fielddef *key_f = map_field_key(f);
const upb_fielddef *val_f = map_field_value(f);
upb_fieldtype_t key_type = upb_fielddef_type(key_f);
TypeInfo value_type_info = TypeInfo_get(val_f);
return Map_GetRubyWrapper(map, key_type, value_type_info, self->arena);
} else if (upb_fielddef_isseq(f)) {
upb_array *arr = upb_msg_mutable(msg, f, arena).array;
return RepeatedField_GetRubyWrapper(arr, TypeInfo_get(f), self->arena);
} else if (upb_fielddef_issubmsg(f)) {
if (!upb_msg_has(self->msg, f)) return Qnil;
upb_msg *submsg = upb_msg_mutable(msg, f, arena).msg;
const upb_msgdef *m = upb_fielddef_msgsubdef(f);
return Message_GetRubyWrapper(submsg, m, self->arena);
} else {
upb_msgval msgval = upb_msg_get(self->msg, f);
return Convert_UpbToRuby(msgval, TypeInfo_get(f), self->arena);
}
case METHOD_GETTER:
return Message_getfield(_self, f);
default:
rb_raise(rb_eRuntimeError, "Internal error, no such accessor: %d",
accessor_type);
}
}
}

Expand Down Expand Up @@ -866,7 +870,6 @@ static VALUE Message_freeze(VALUE _self) {
static VALUE Message_index(VALUE _self, VALUE field_name) {
Message* self = ruby_to_Message(_self);
const upb_fielddef* field;
upb_msgval val;

Check_Type(field_name, T_STRING);
field = upb_msgdef_ntofz(self->msgdef, RSTRING_PTR(field_name));
Expand All @@ -875,8 +878,7 @@ static VALUE Message_index(VALUE _self, VALUE field_name) {
return Qnil;
}

val = upb_msg_get(self->msg, field);
return Convert_UpbToRuby(val, TypeInfo_get(field), self->arena);
return Message_getfield(_self, field);
}

/*
Expand Down Expand Up @@ -1285,7 +1287,7 @@ const upb_msg* Message_GetUpbMessage(VALUE value, const upb_msgdef* m,
if (!rb_obj_is_kind_of(value, rb_cNumeric)) goto badtype;

sec.int64_val = NUM2LL(value);
nsec.int32_val = (NUM2DBL(value) - NUM2LL(value)) * 1000000000;
nsec.int32_val = round((NUM2DBL(value) - NUM2LL(value)) * 1000000000);
upb_msg_set(msg, sec_f, sec, arena);
upb_msg_set(msg, nsec_f, nsec, arena);
return msg;
Expand Down
2 changes: 1 addition & 1 deletion ruby/google-protobuf.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
s.version = "3.15.0"
s.version = "3.15.1"
git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
s.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers"
Expand Down
27 changes: 27 additions & 0 deletions ruby/tests/basic.rb
Expand Up @@ -31,6 +31,33 @@ def proto_module
end
include CommonTests

def test_issue_8311_crash
Google::Protobuf::DescriptorPool.generated_pool.build do
add_file("inner.proto", :syntax => :proto3) do
add_message "Inner" do
# Removing either of these fixes the segfault.
optional :foo, :string, 1
optional :bar, :string, 2
end
end
end

Google::Protobuf::DescriptorPool.generated_pool.build do
add_file("outer.proto", :syntax => :proto3) do
add_message "Outer" do
repeated :inners, :message, 1, "Inner"
end
end
end

outer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Outer").msgclass

outer_proto = outer.new(
inners: []
)
outer_proto['inners'].to_s
end

def test_has_field
m = TestSingularFields.new
assert !m.has_singular_msg?
Expand Down
6 changes: 6 additions & 0 deletions ruby/tests/common_tests.rb
Expand Up @@ -1701,6 +1701,12 @@ def test_converts_duration
m = proto_module::TimeMessage.new(duration: 1.1)
assert_equal Google::Protobuf::Duration.new(seconds: 1, nanos: 100_000_000), m.duration

m = proto_module::TimeMessage.new(duration: 123.321)
assert_equal Google::Protobuf::Duration.new(seconds: 123, nanos: 321_000_000), m.duration

m = proto_module::TimeMessage.new(duration: -123.321)
assert_equal Google::Protobuf::Duration.new(seconds: -123, nanos: -321_000_000), m.duration

assert_raise(Google::Protobuf::TypeError) { m.duration = '2' }
assert_raise(Google::Protobuf::TypeError) { m.duration = proto_module::TimeMessage.new }
end
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Expand Up @@ -18,7 +18,7 @@ else
PTHREAD_DEF =
endif

PROTOBUF_VERSION = 26:0:0
PROTOBUF_VERSION = 26:1:0

if GCC
# Turn on all warnings except for sign comparison (we ignore sign comparison
Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/any.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/google/protobuf/api.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/google/protobuf/compiler/plugin.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/google/protobuf/descriptor.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/google/protobuf/duration.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/google/protobuf/empty.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/google/protobuf/field_mask.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 326ea55

Please sign in to comment.