diff options
author | Chris Fallin <cfallin@google.com> | 2015-02-02 13:03:08 -0800 |
---|---|---|
committer | Chris Fallin <cfallin@google.com> | 2015-02-02 13:03:08 -0800 |
commit | eb33f9d3d6f1f78ee70f4bea4326adaf035e1e67 (patch) | |
tree | 3d3bd24d98f81fcdea8a2c819e1fb49faca08042 /ruby/ext/google/protobuf_c/encode_decode.c | |
parent | 07b8b0f28d1ad88c7c1c64e8707dab8537313c26 (diff) | |
download | protobuf-eb33f9d3d6f1f78ee70f4bea4326adaf035e1e67.tar.gz protobuf-eb33f9d3d6f1f78ee70f4bea4326adaf035e1e67.tar.bz2 protobuf-eb33f9d3d6f1f78ee70f4bea4326adaf035e1e67.zip |
Updated based on code-review comments.
Diffstat (limited to 'ruby/ext/google/protobuf_c/encode_decode.c')
-rw-r--r-- | ruby/ext/google/protobuf_c/encode_decode.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c index b9ecd456..0630f567 100644 --- a/ruby/ext/google/protobuf_c/encode_decode.c +++ b/ruby/ext/google/protobuf_c/encode_decode.c @@ -359,9 +359,12 @@ static void *oneofsubmsg_handler(void *closure, DEREF(msg, oneofdata->ofs, VALUE) = rb_class_new_instance(0, NULL, subklass); } - // Set the oneof case *after* allocating the new class instance -- see comment - // in layout_set() as to why. There are subtle interactions with possible GC - // points and oneof field type transitions. + // Set the oneof case *after* allocating the new class instance -- otherwise, + // if the Ruby GC is invoked as part of a call into the VM, it might invoke + // our mark routines, and our mark routines might see the case value + // indicating a VALUE is present and expect a valid VALUE. See comment in + // layout_set() for more detail: basically, the change to the value and the + // case must be atomic w.r.t. the Ruby VM. DEREF(msg, oneofdata->case_ofs, uint32_t) = oneofdata->oneof_case_num; |