Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
b245551a
Commit
b245551a
authored
Aug 20, 2019
by
Joshua Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for race in lazy initialization of handlers.
This fixes
https://github.com/protocolbuffers/protobuf/issues/6532
.
parent
ee4f2492
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
defs.c
ruby/ext/google/protobuf_c/defs.c
+21
-0
No files found.
ruby/ext/google/protobuf_c/defs.c
View file @
b245551a
...
...
@@ -2228,6 +2228,27 @@ static VALUE get_def_obj(VALUE _descriptor_pool, const void* ptr, VALUE klass) {
VALUE
args
[
3
]
=
{
c_only_cookie
,
_descriptor_pool
,
key
};
def
=
rb_class_new_instance
(
3
,
args
,
klass
);
rb_hash_aset
(
descriptor_pool
->
def_to_descriptor
,
key
,
def
);
// For message defs, we now eagerly get/create descriptors for all
// submessages. We will need these anyway to parse or serialize this
// message type. But more importantly, we must do this now so that
// add_handlers_for_message() (which calls get_msgdef_obj()) does *not*
// need to create a Ruby object or insert into a Ruby Hash. We need to
// avoid triggering GC, which can switch Ruby threads and re-enter our
// C extension from a different thread. This wreaks havoc on our state
// if we were in the middle of building handlers.
if
(
klass
==
cDescriptor
)
{
const
upb_msgdef
*
m
=
ptr
;
upb_msg_field_iter
it
;
for
(
upb_msg_field_begin
(
&
it
,
m
);
!
upb_msg_field_done
(
&
it
);
upb_msg_field_next
(
&
it
))
{
const
upb_fielddef
*
f
=
upb_msg_iter_field
(
&
it
);
if
(
upb_fielddef_issubmsg
(
f
))
{
get_msgdef_obj
(
_descriptor_pool
,
upb_fielddef_msgsubdef
(
f
));
}
}
}
}
return
def
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment