aboutsummaryrefslogtreecommitdiff
path: root/ruby/ext/google/protobuf_c/protobuf.c
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2017-10-03 17:28:49 -0700
committerGitHub <noreply@github.com>2017-10-03 17:28:49 -0700
commitcd5f49d0942e19a5854a325941918fca02fdb409 (patch)
treee4fde8a62907668dbada9c3332f181faf375c645 /ruby/ext/google/protobuf_c/protobuf.c
parentd6c32a818fd8590e1758d1ed86107a967468d1b6 (diff)
downloadprotobuf-cd5f49d0942e19a5854a325941918fca02fdb409.tar.gz
protobuf-cd5f49d0942e19a5854a325941918fca02fdb409.tar.bz2
protobuf-cd5f49d0942e19a5854a325941918fca02fdb409.zip
Fix ruby segment fault (#3708)
* Fix ruby segment fault 1) rb_ary_new cannot be called during allocate function. During allocate fucntion, the containing object hasn't been marked and rb_ary_new may invoke gc to collect containing object. 2) The global map should be marked before allocating it. Otherwise it may be garbage collected. * Add test * Remove commented code * Fix grammer error
Diffstat (limited to 'ruby/ext/google/protobuf_c/protobuf.c')
-rw-r--r--ruby/ext/google/protobuf_c/protobuf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c
index 7cde4aec..c7750c44 100644
--- a/ruby/ext/google/protobuf_c/protobuf.c
+++ b/ruby/ext/google/protobuf_c/protobuf.c
@@ -110,6 +110,6 @@ void Init_protobuf_c() {
kRubyStringASCIIEncoding = rb_usascii_encoding();
kRubyString8bitEncoding = rb_ascii8bit_encoding();
- upb_def_to_ruby_obj_map = rb_hash_new();
rb_gc_register_address(&upb_def_to_ruby_obj_map);
+ upb_def_to_ruby_obj_map = rb_hash_new();
}