Merge pull request #8348 from acozzette/3.15.x-202102251545

Merge 3.15.x into master
pull/8351/head
Adam Cozzette 4 years ago committed by GitHub
commit 8080bebf1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      CHANGES.txt
  2. 2
      Protobuf-C++.podspec
  3. 2
      Protobuf.podspec
  4. 2
      configure.ac
  5. 2
      csharp/Google.Protobuf.Tools.nuspec
  6. 2
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  7. 2
      java/bom/pom.xml
  8. 2
      java/core/pom.xml
  9. 2
      java/lite/pom.xml
  10. 2
      java/pom.xml
  11. 2
      java/util/pom.xml
  12. 2
      js/package.json
  13. 23
      php/ext/google/protobuf/package.xml
  14. 2
      php/ext/google/protobuf/protobuf.h
  15. 2
      protoc-artifacts/pom.xml
  16. 2
      python/google/protobuf/__init__.py
  17. 2
      ruby/ext/google/protobuf_c/defs.c
  18. 9
      ruby/ext/google/protobuf_c/map.c
  19. 6
      ruby/ext/google/protobuf_c/message.c
  20. 172
      ruby/ext/google/protobuf_c/protobuf.c
  21. 17
      ruby/ext/google/protobuf_c/protobuf.h
  22. 9
      ruby/ext/google/protobuf_c/repeated_field.c
  23. 2
      ruby/google-protobuf.gemspec
  24. 2
      src/Makefile.am
  25. 2
      src/google/protobuf/any.pb.h
  26. 2
      src/google/protobuf/api.pb.h
  27. 2
      src/google/protobuf/compiler/plugin.pb.h
  28. 2
      src/google/protobuf/descriptor.pb.h
  29. 2
      src/google/protobuf/duration.pb.h
  30. 2
      src/google/protobuf/empty.pb.h
  31. 2
      src/google/protobuf/field_mask.pb.h
  32. 2
      src/google/protobuf/port_def.inc
  33. 2
      src/google/protobuf/source_context.pb.h
  34. 2
      src/google/protobuf/struct.pb.h
  35. 2
      src/google/protobuf/stubs/common.h
  36. 2
      src/google/protobuf/timestamp.pb.h
  37. 2
      src/google/protobuf/type.pb.h
  38. 2
      src/google/protobuf/wrappers.pb.h

@ -1,3 +1,8 @@
2021-02-25 version 3.15.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Ruby
* Ruby <2.7 now uses WeakMap too, which prevents memory leaks. (#8341)
2021-02-23 version 3.15.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) 2021-02-23 version 3.15.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Ruby Ruby

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Protobuf-C++' s.name = 'Protobuf-C++'
s.version = '3.15.2' s.version = '3.15.3'
s.summary = 'Protocol Buffers v3 runtime library for C++.' s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/protobuf' s.homepage = 'https://github.com/google/protobuf'
s.license = '3-Clause BSD License' s.license = '3-Clause BSD License'

@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library. # dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Protobuf' s.name = 'Protobuf'
s.version = '3.15.2' s.version = '3.15.3'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf' s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = '3-Clause BSD License' s.license = '3-Clause BSD License'

@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release # 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 # 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.) # the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[3.15.2],[protobuf@googlegroups.com],[protobuf]) AC_INIT([Protocol Buffers],[3.15.3],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable]) AM_MAINTAINER_MODE([enable])

@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title> <title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary> <summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description> <description>See project site for more info.</description>
<version>3.15.2</version> <version>3.15.3</version>
<authors>Google Inc.</authors> <authors>Google Inc.</authors>
<owners>protobuf-packages</owners> <owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl> <licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>

@ -4,7 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description> <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright> <Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle> <AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.15.2</VersionPrefix> <VersionPrefix>3.15.3</VersionPrefix>
<!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence --> <!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
<LangVersion>7.2</LangVersion> <LangVersion>7.2</LangVersion>
<Authors>Google Inc.</Authors> <Authors>Google Inc.</Authors>

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId> <artifactId>protobuf-bom</artifactId>
<version>3.15.2</version> <version>3.15.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Protocol Buffers [BOM]</name> <name>Protocol Buffers [BOM]</name>

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.15.2</version> <version>3.15.3</version>
</parent> </parent>
<artifactId>protobuf-java</artifactId> <artifactId>protobuf-java</artifactId>

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.15.2</version> <version>3.15.3</version>
</parent> </parent>
<artifactId>protobuf-javalite</artifactId> <artifactId>protobuf-javalite</artifactId>

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.15.2</version> <version>3.15.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Protocol Buffers [Parent]</name> <name>Protocol Buffers [Parent]</name>

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.15.2</version> <version>3.15.3</version>
</parent> </parent>
<artifactId>protobuf-java-util</artifactId> <artifactId>protobuf-java-util</artifactId>

@ -1,6 +1,6 @@
{ {
"name": "google-protobuf", "name": "google-protobuf",
"version": "3.15.2", "version": "3.15.3",
"description": "Protocol Buffers for JavaScript", "description": "Protocol Buffers for JavaScript",
"main": "google-protobuf.js", "main": "google-protobuf.js",
"files": [ "files": [

@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email> <email>protobuf-opensource@google.com</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2021-02-23</date> <date>2021-02-24</date>
<time>11:35:09</time> <time>16:49:52</time>
<version> <version>
<release>3.15.2</release> <release>3.15.3</release>
<api>3.15.2</api> <api>3.15.3</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -835,5 +835,20 @@ G A release.
<notes> <notes>
</notes> </notes>
</release> </release>
<release>
<version>
<release>3.15.3</release>
<api>3.15.3</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2021-02-24</date>
<time>16:49:52</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>
</notes>
</release>
</changelog> </changelog>
</package> </package>

@ -76,7 +76,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1)
ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()
#define PHP_PROTOBUF_VERSION "3.15.2" #define PHP_PROTOBUF_VERSION "3.15.3"
// ptr -> PHP object cache. This is a weak map that caches lazily-created // ptr -> PHP object cache. This is a weak map that caches lazily-created
// wrapper objects around upb types: // wrapper objects around upb types:

@ -8,7 +8,7 @@
</parent> </parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId> <artifactId>protoc</artifactId>
<version>3.15.2</version> <version>3.15.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Protobuf Compiler</name> <name>Protobuf Compiler</name>
<description> <description>

@ -30,4 +30,4 @@
# Copyright 2007 Google Inc. All Rights Reserved. # Copyright 2007 Google Inc. All Rights Reserved.
__version__ = '3.15.2' __version__ = '3.15.3'

@ -295,7 +295,7 @@ static VALUE DescriptorPool_alloc(VALUE klass) {
self->def_to_descriptor = rb_hash_new(); self->def_to_descriptor = rb_hash_new();
self->symtab = upb_symtab_new(); self->symtab = upb_symtab_new();
ObjectCache_Add(self->symtab, ret, _upb_symtab_arena(self->symtab)); ObjectCache_Add(self->symtab, ret);
return ret; return ret;
} }

@ -93,7 +93,7 @@ VALUE Map_GetRubyWrapper(upb_map* map, upb_fieldtype_t key_type,
if (val == Qnil) { if (val == Qnil) {
val = Map_alloc(cMap); val = Map_alloc(cMap);
Map* self; Map* self;
ObjectCache_Add(map, val, Arena_get(arena)); ObjectCache_Add(map, val);
TypedData_Get_Struct(val, Map, &Map_type, self); TypedData_Get_Struct(val, Map, &Map_type, self);
self->map = map; self->map = map;
self->arena = arena; self->arena = arena;
@ -318,7 +318,7 @@ static VALUE Map_init(int argc, VALUE* argv, VALUE _self) {
self->map = upb_map_new(Arena_get(self->arena), self->key_type, self->map = upb_map_new(Arena_get(self->arena), self->key_type,
self->value_type_info.type); self->value_type_info.type);
ObjectCache_Add(self->map, _self, Arena_get(self->arena)); ObjectCache_Add(self->map, _self);
if (init_arg != Qnil) { if (init_arg != Qnil) {
Map_merge_into_self(_self, init_arg); Map_merge_into_self(_self, init_arg);
@ -590,9 +590,10 @@ VALUE Map_eq(VALUE _self, VALUE _other) {
*/ */
static VALUE Map_freeze(VALUE _self) { static VALUE Map_freeze(VALUE _self) {
Map* self = ruby_to_Map(_self); Map* self = ruby_to_Map(_self);
if (!RB_OBJ_FROZEN(_self)) {
ObjectCache_Pin(self->map, _self, Arena_get(self->arena)); Arena_Pin(self->arena, _self);
RB_OBJ_FREEZE(_self); RB_OBJ_FREEZE(_self);
}
return _self; return _self;
} }

@ -105,7 +105,7 @@ void Message_InitPtr(VALUE self_, upb_msg *msg, VALUE arena) {
Message* self = ruby_to_Message(self_); Message* self = ruby_to_Message(self_);
self->msg = msg; self->msg = msg;
self->arena = arena; self->arena = arena;
ObjectCache_Add(msg, self_, Arena_get(arena)); ObjectCache_Add(msg, self_);
} }
VALUE Message_GetArena(VALUE msg_rb) { VALUE Message_GetArena(VALUE msg_rb) {
@ -855,8 +855,10 @@ static VALUE Message_to_h(VALUE _self) {
*/ */
static VALUE Message_freeze(VALUE _self) { static VALUE Message_freeze(VALUE _self) {
Message* self = ruby_to_Message(_self); Message* self = ruby_to_Message(_self);
ObjectCache_Pin(self->msg, _self, Arena_get(self->arena)); if (!RB_OBJ_FROZEN(_self)) {
Arena_Pin(self->arena, _self);
RB_OBJ_FREEZE(_self); RB_OBJ_FREEZE(_self);
}
return _self; return _self;
} }

@ -167,30 +167,55 @@ void StringBuilder_PrintMsgval(StringBuilder* b, upb_msgval val,
// Arena // Arena
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Arena_free(void* data) { upb_arena_free(data); } typedef struct {
upb_arena *arena;
VALUE pinned_objs;
} Arena;
static void Arena_mark(void *data) {
Arena *arena = data;
rb_gc_mark(arena->pinned_objs);
}
static void Arena_free(void *data) {
Arena *arena = data;
upb_arena_free(arena->arena);
}
static VALUE cArena; static VALUE cArena;
const rb_data_type_t Arena_type = { const rb_data_type_t Arena_type = {
"Google::Protobuf::Internal::Arena", "Google::Protobuf::Internal::Arena",
{ NULL, Arena_free, NULL }, { Arena_mark, Arena_free, NULL },
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
}; };
static VALUE Arena_alloc(VALUE klass) { static VALUE Arena_alloc(VALUE klass) {
upb_arena *arena = upb_arena_new(); Arena *arena = ALLOC(Arena);
arena->arena = upb_arena_new();
arena->pinned_objs = Qnil;
return TypedData_Wrap_Struct(klass, &Arena_type, arena); return TypedData_Wrap_Struct(klass, &Arena_type, arena);
} }
upb_arena *Arena_get(VALUE _arena) { upb_arena *Arena_get(VALUE _arena) {
upb_arena *arena; Arena *arena;
TypedData_Get_Struct(_arena, upb_arena, &Arena_type, arena); TypedData_Get_Struct(_arena, Arena, &Arena_type, arena);
return arena; return arena->arena;
} }
VALUE Arena_new() { VALUE Arena_new() {
return Arena_alloc(cArena); return Arena_alloc(cArena);
} }
void Arena_Pin(VALUE _arena, VALUE obj) {
Arena *arena;
TypedData_Get_Struct(_arena, Arena, &Arena_type, arena);
if (arena->pinned_objs == Qnil) {
arena->pinned_objs = rb_ary_new();
}
rb_ary_push(arena->pinned_objs, obj);
}
void Arena_register(VALUE module) { void Arena_register(VALUE module) {
VALUE internal = rb_define_module_under(module, "Internal"); VALUE internal = rb_define_module_under(module, "Internal");
VALUE klass = rb_define_class_under(internal, "Arena", rb_cObject); VALUE klass = rb_define_class_under(internal, "Arena", rb_cObject);
@ -209,122 +234,79 @@ void Arena_register(VALUE module) {
// different wrapper objects for the same C object, which saves memory and // different wrapper objects for the same C object, which saves memory and
// preserves object identity. // preserves object identity.
// //
// We use Hash and/or WeakMap for the cache. WeakMap is faster overall // We use WeakMap for the cache. For Ruby <2.7 we also need a secondary Hash
// (probably due to removal being integrated with GC) but doesn't work for Ruby // to store WeakMap keys because Ruby <2.7 WeakMap doesn't allow non-finalizable
// <2.7 (see note below). We need Hash for Ruby <2.7 and for cases where we // keys.
// need to GC-root the object (notably when the object has been frozen).
#if RUBY_API_VERSION_CODE >= 20700 #if RUBY_API_VERSION_CODE >= 20700
#define USE_WEAK_MAP 1 #define USE_SECONDARY_MAP 0
#else #else
#define USE_WEAK_MAP 0 #define USE_SECONDARY_MAP 1
#endif #endif
static VALUE ObjectCache_GetKey(const void* key) { #if USE_SECONDARY_MAP
char buf[sizeof(key)];
memcpy(&buf, &key, sizeof(key));
intptr_t key_int = (intptr_t)key;
PBRUBY_ASSERT((key_int & 3) == 0);
return LL2NUM(key_int >> 2);
}
// Strong object cache, uses regular Hash and GC-roots objects. // Maps Numeric -> Object. The object is then used as a key into the WeakMap.
// - For Ruby <2.7, used for all objects. // This is needed for Ruby <2.7 where a number cannot be a key to WeakMap.
// - For Ruby >=2.7, used only for frozen objects, so we preserve the "frozen" // The object is used only for its identity; it does not contain any data.
// bit (since this information is not preserved at the upb level). VALUE secondary_map = Qnil;
VALUE strong_obj_cache = Qnil; static void SecondaryMap_Init() {
rb_gc_register_address(&secondary_map);
static void StrongObjectCache_Init() { secondary_map = rb_hash_new();
rb_gc_register_address(&strong_obj_cache);
strong_obj_cache = rb_hash_new();
} }
static void StrongObjectCache_Remove(void* key) { static VALUE SecondaryMap_Get(VALUE key) {
VALUE key_rb = ObjectCache_GetKey(key); VALUE ret = rb_hash_lookup(secondary_map, key);
PBRUBY_ASSERT(rb_hash_lookup(strong_obj_cache, key_rb) != Qnil); if (ret == Qnil) {
rb_hash_delete(strong_obj_cache, key_rb); ret = rb_eval_string("Object.new");
rb_hash_aset(secondary_map, key, ret);
} }
return ret;
static VALUE StrongObjectCache_Get(const void* key) {
VALUE key_rb = ObjectCache_GetKey(key);
return rb_hash_lookup(strong_obj_cache, key_rb);
} }
static void StrongObjectCache_Add(const void* key, VALUE val, #endif
upb_arena* arena) {
PBRUBY_ASSERT(StrongObjectCache_Get(key) == Qnil);
VALUE key_rb = ObjectCache_GetKey(key);
rb_hash_aset(strong_obj_cache, key_rb, val);
upb_arena_addcleanup(arena, (void*)key, StrongObjectCache_Remove);
}
// Weak object cache. This speeds up the test suite significantly, so we static VALUE ObjectCache_GetKey(const void* key) {
// presume it speeds up real code also. However we can only use it in Ruby char buf[sizeof(key)];
// >=2.7 due to: memcpy(&buf, &key, sizeof(key));
// https://bugs.ruby-lang.org/issues/16035 intptr_t key_int = (intptr_t)key;
PBRUBY_ASSERT((key_int & 3) == 0);
VALUE ret = LL2NUM(key_int >> 2);
#if USE_SECONDARY_MAP
ret = SecondaryMap_Get(ret);
#endif
return ret;
}
#if USE_WEAK_MAP // Public ObjectCache API.
VALUE weak_obj_cache = Qnil; VALUE weak_obj_cache = Qnil;
ID item_get;
ID item_set;
static void WeakObjectCache_Init() { static void ObjectCache_Init() {
rb_gc_register_address(&weak_obj_cache); rb_gc_register_address(&weak_obj_cache);
VALUE klass = rb_eval_string("ObjectSpace::WeakMap"); VALUE klass = rb_eval_string("ObjectSpace::WeakMap");
weak_obj_cache = rb_class_new_instance(0, NULL, klass); weak_obj_cache = rb_class_new_instance(0, NULL, klass);
} item_get = rb_intern("[]");
item_set = rb_intern("[]=");
static VALUE WeakObjectCache_Get(const void* key) { #if USE_SECONDARY_MAP
VALUE key_rb = ObjectCache_GetKey(key); SecondaryMap_Init();
VALUE ret = rb_funcall(weak_obj_cache, rb_intern("[]"), 1, key_rb);
return ret;
}
static void WeakObjectCache_Add(const void* key, VALUE val) {
PBRUBY_ASSERT(WeakObjectCache_Get(key) == Qnil);
VALUE key_rb = ObjectCache_GetKey(key);
rb_funcall(weak_obj_cache, rb_intern("[]="), 2, key_rb, val);
PBRUBY_ASSERT(WeakObjectCache_Get(key) == val);
}
#endif
// Public ObjectCache API.
static void ObjectCache_Init() {
StrongObjectCache_Init();
#if USE_WEAK_MAP
WeakObjectCache_Init();
#endif #endif
} }
void ObjectCache_Add(const void* key, VALUE val, upb_arena *arena) { void ObjectCache_Add(const void* key, VALUE val) {
#if USE_WEAK_MAP PBRUBY_ASSERT(ObjectCache_Get(key) == Qnil);
(void)arena; VALUE key_rb = ObjectCache_GetKey(key);
WeakObjectCache_Add(key, val); rb_funcall(weak_obj_cache, item_set, 2, key_rb, val);
#else PBRUBY_ASSERT(ObjectCache_Get(key) == val);
StrongObjectCache_Add(key, val, arena);
#endif
} }
// Returns the cached object for this key, if any. Otherwise returns Qnil. // Returns the cached object for this key, if any. Otherwise returns Qnil.
VALUE ObjectCache_Get(const void* key) { VALUE ObjectCache_Get(const void* key) {
#if USE_WEAK_MAP VALUE key_rb = ObjectCache_GetKey(key);
return WeakObjectCache_Get(key); return rb_funcall(weak_obj_cache, item_get, 1, key_rb);
#else
return StrongObjectCache_Get(key);
#endif
}
void ObjectCache_Pin(const void* key, VALUE val, upb_arena *arena) {
#if USE_WEAK_MAP
PBRUBY_ASSERT(WeakObjectCache_Get(key) == val);
// This will GC-root the object, but we'll still use the weak map for
// actual lookup.
StrongObjectCache_Add(key, val, arena);
#else
// Value is already pinned, nothing to do.
#endif
} }
/* /*

@ -55,6 +55,13 @@ const upb_fielddef* map_field_value(const upb_fielddef* field);
VALUE Arena_new(); VALUE Arena_new();
upb_arena *Arena_get(VALUE arena); upb_arena *Arena_get(VALUE arena);
// Pins this Ruby object to the lifetime of this arena, so that as long as the
// arena is alive this object will not be collected.
//
// We use this to guarantee that the "frozen" bit on the object will be
// remembered, even if the user drops their reference to this precise object.
void Arena_Pin(VALUE arena, VALUE obj);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ObjectCache // ObjectCache
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -68,19 +75,11 @@ upb_arena *Arena_get(VALUE arena);
// Adds an entry to the cache. The "arena" parameter must give the arena that // Adds an entry to the cache. The "arena" parameter must give the arena that
// "key" was allocated from. In Ruby <2.7.0, it will be used to remove the key // "key" was allocated from. In Ruby <2.7.0, it will be used to remove the key
// from the cache when the arena is destroyed. // from the cache when the arena is destroyed.
void ObjectCache_Add(const void* key, VALUE val, upb_arena *arena); void ObjectCache_Add(const void* key, VALUE val);
// Returns the cached object for this key, if any. Otherwise returns Qnil. // Returns the cached object for this key, if any. Otherwise returns Qnil.
VALUE ObjectCache_Get(const void* key); VALUE ObjectCache_Get(const void* key);
// Pins the previously added object so it is GC-rooted. This turns the
// reference to "val" from weak to strong. We use this to guarantee that the
// "frozen" bit on the object will be remembered, even if the user drops their
// reference to this precise object.
//
// The "arena" parameter must give the arena that "key" was allocated from.
void ObjectCache_Pin(const void* key, VALUE val, upb_arena *arena);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// StringBuilder, for inspect // StringBuilder, for inspect
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

@ -88,7 +88,7 @@ VALUE RepeatedField_GetRubyWrapper(upb_array* array, TypeInfo type_info,
if (val == Qnil) { if (val == Qnil) {
val = RepeatedField_alloc(cRepeatedField); val = RepeatedField_alloc(cRepeatedField);
RepeatedField* self; RepeatedField* self;
ObjectCache_Add(array, val, Arena_get(arena)); ObjectCache_Add(array, val);
TypedData_Get_Struct(val, RepeatedField, &RepeatedField_type, self); TypedData_Get_Struct(val, RepeatedField, &RepeatedField_type, self);
self->array = array; self->array = array;
self->arena = arena; self->arena = arena;
@ -500,9 +500,10 @@ VALUE RepeatedField_eq(VALUE _self, VALUE _other) {
*/ */
static VALUE RepeatedField_freeze(VALUE _self) { static VALUE RepeatedField_freeze(VALUE _self) {
RepeatedField* self = ruby_to_RepeatedField(_self); RepeatedField* self = ruby_to_RepeatedField(_self);
if (!RB_OBJ_FROZEN(_self)) {
ObjectCache_Pin(self->array, _self, Arena_get(self->arena)); Arena_Pin(self->arena, _self);
RB_OBJ_FREEZE(_self); RB_OBJ_FREEZE(_self);
}
return _self; return _self;
} }
@ -610,7 +611,7 @@ VALUE RepeatedField_init(int argc, VALUE* argv, VALUE _self) {
self->type_info = TypeInfo_FromClass(argc, argv, 0, &self->type_class, &ary); self->type_info = TypeInfo_FromClass(argc, argv, 0, &self->type_class, &ary);
self->array = upb_array_new(arena, self->type_info.type); self->array = upb_array_new(arena, self->type_info.type);
ObjectCache_Add(self->array, _self, arena); ObjectCache_Add(self->array, _self);
if (ary != Qnil) { if (ary != Qnil) {
if (!RB_TYPE_P(ary, T_ARRAY)) { if (!RB_TYPE_P(ary, T_ARRAY)) {

@ -1,6 +1,6 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "google-protobuf" s.name = "google-protobuf"
s.version = "3.15.2" s.version = "3.15.3"
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 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.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers" s.summary = "Protocol Buffers"

@ -18,7 +18,7 @@ else
PTHREAD_DEF = PTHREAD_DEF =
endif endif
PROTOBUF_VERSION = 26:2:0 PROTOBUF_VERSION = 26:3:0
if GCC if GCC
# Turn on all warnings except for sign comparison (we ignore sign comparison # Turn on all warnings except for sign comparison (we ignore sign comparison

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -335,7 +335,7 @@
// Shared google3/opensource definitions. ////////////////////////////////////// // Shared google3/opensource definitions. //////////////////////////////////////
#define PROTOBUF_VERSION 3015002 #define PROTOBUF_VERSION 3015003
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000 #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000
#define PROTOBUF_MIN_PROTOC_VERSION 3015000 #define PROTOBUF_MIN_PROTOC_VERSION 3015000
#define PROTOBUF_VERSION_SUFFIX "" #define PROTOBUF_VERSION_SUFFIX ""

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -82,7 +82,7 @@ namespace internal {
// The current version, represented as a single integer to make comparison // The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro // easier: major * 10^6 + minor * 10^3 + micro
#define GOOGLE_PROTOBUF_VERSION 3015002 #define GOOGLE_PROTOBUF_VERSION 3015003
// A suffix string for alpha, beta or rc releases. Empty for stable releases. // A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX "" #define GOOGLE_PROTOBUF_VERSION_SUFFIX ""

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update
#error your headers. #error your headers.
#endif #endif
#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION #if 3015003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is #error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please #error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc. #error regenerate this file with a newer version of protoc.

Loading…
Cancel
Save