-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segfault when ruby-protobuf decodes lots of messages with maps concurrently #3250
Comments
Thanks so much for the detailed repro! This should make it not too difficult to get to the bottom of this. |
Hello @haberman , Is there any update on this issue ? We are still struggling with few random segfault on our platform. Also we have some issues when unmarshalling big map objects with concurrency. Regards |
Hi. I think that the SEGV is due to the fact that the decoder is using a global variable to keep state. The comment says that it doesn't allow concurrent decodes, but I don't see any mechanisms that would actually prevent that. That means if there are threads, the array could be in an unknown state. I rewrote the example a little to isolate the decoder: require_relative 'repro_pb'
thds = []
o = Repro::Outer.new
o.items[0] = Repro::Inner.new
raw = Repro::Outer.encode(o)
thds = 2.times.map do
Thread.new do
100000.times do
Repro::Outer.decode(raw)
end
end
end
thds.each(&:join) This narrows the problem to the decoder. I think #3560 will fix this. It fixes the repro case. I am just not sure if |
This makes the frame stack per-parser, and per-thread. Fixes protocolbuffers#3250
@apolcyn Can you make a minor release of |
IIC, grpc shouldn't need a new release, since the fix for this is in |
This makes the frame stack per-parser, and per-thread. Fixes protocolbuffers#3250
When looking into a grpc-ruby crash described in grpc/grpc#11331, it looks like the repro could be trimmed down to include only the ruby
google/protobuf
library.What seems necessary to trigger the crash is:
map
types with any key type and a value of a Message type.decode
these messagesThe minimal repro seems to be:
repro.proto
:In the same directory, the
repro.rb
file looks like:repro_pb.rb
was generated with:see generated repro_pb.rb
After generating, running
ruby repro.rb
should segfault during adecode
call (I'm seeing it repro about 9/10 tries - increasing the number of calls toRepro::Outer.decode
seems to cause it more frequently):example stack trace
Environment details:
protoc --version
giveslibprotoc 3.3.0
(protoc built from head of grpc repo with
make plugins
, and used from the<grpc_repo>/bins/opt/protobuf/protoc
)gem list google-protobuf
givesgoogle-protobuf (3.3.0 x86_64-linux)
ruby platform:
x86_64-linux
ruby version: 2.4.0
The text was updated successfully, but these errors were encountered: