Add ruby_upb_alloc using xrealloc/xfree so Ruby GC is aware of allocated memory for Arenas. (#9586)
* Add ruby-specific upb_alloc using xrealloc/xfree for use in Arena_alloc so Ruby GC is aware of allocated memory.
* Add RB_GC_GUARD to DescriptorPool_add_serialized_file to ensure ruby does not aggressively garbage collect arena_rb due to lack of references.
diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c
index aaa8b4d..3bd18e8 100644
--- a/ruby/ext/google/protobuf_c/defs.c
+++ b/ruby/ext/google/protobuf_c/defs.c
@@ -159,6 +159,7 @@
rb_raise(cTypeError, "Unable to build file to DescriptorPool: %s",
upb_Status_ErrorMessage(&status));
}
+ RB_GC_GUARD(arena_rb);
return get_filedef_obj(_self, filedef);
}