Skip to content
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

Ruby: Segfault when accessing empty repeated field via hash #8311

Closed
hatstand opened this issue Feb 19, 2021 · 4 comments
Closed

Ruby: Segfault when accessing empty repeated field via hash #8311

hatstand opened this issue Feb 19, 2021 · 4 comments

Comments

@hatstand
Copy link

What version of protobuf and what language are you using?
Version: 3.15.0
Language: Ruby

What operating system (Linux, Windows, ...) and version?
Linux Debian 10.5
(Docker ruby:2.7.1-slim)

What runtime / compiler are you using (e.g., python version or gcc version)
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

What did you do?

  1. Construct a message containing a repeated field and assign an empty array to the repeated field. It seems the inner field must also be a message with at least two fields.
  2. Access that field as a hash and call to_s
  3. Segfault!

Minimal reproduction:

require 'google/protobuf'

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file("inner.proto", :syntax => :proto3) do
    add_message "Inner" do
      # Removing either of these fixes the segfault.
      optional :foo, :string, 1
      optional :bar, :string, 2
    end
  end
end

Inner = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Inner").msgclass

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file("outer.proto", :syntax => :proto3) do
    add_message "Outer" do
      repeated :inners, :message, 1, "Inner"
    end
  end
end

Outer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Outer").msgclass

outer_proto = Outer.new(
  inners: []
)
# Uncommenting the next line will fix the segfault.
# outer_proto.inners
# Printing `outer_proto['inners'].class` here will print `Inner` rather than `Google::Protobuf::RepeatedField`
outer_proto['inners'].to_s

What did you expect to see
Not segfault

What did you see instead?

root@d0e7eda8eb5a:/home/app/repo# bundle exec ruby --disable-did_you_mean ./repro.rb 
./repro.rb:30: [BUG] Segmentation fault at 0x0000000000000004
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0003 p:---- s:0011 e:000010 CFUNC  :to_s
c:0002 p:0140 s:0007 E:002548 EVAL   ./repro.rb:30 [FINISH]
c:0001 p:0000 s:0003 E:000230 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
./repro.rb:30:in `<main>'
./repro.rb:30:in `to_s'

-- Machine register context ------------------------------------------------
 RIP: 0x00007f4b60d6001c RBP: 0x00007f4b5933402f RSP: 0x00007ffda6ffe278
 RAX: 0x0000000000000000 RBX: 0x00007ffda6ffe360 RCX: 0x0000000000000004
 RDX: 0x00000000607811a0 RDI: 0x0000000000000004 RSI: 0x0000000000000000
  R8: 0x0000000000000000  R9: 0x0000000000000000 R10: 0x0000000000000000
 R11: 0x00000000607811a0 R12: 0x0000000000000004 R13: 0x00000000607811a0
 R14: 0x0000000000000073 R15: 0x00007ffda6ffe960 EFL: 0x0000000000010287

-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.2.7(rb_vm_bugreport+0x555) [0x7f4b614e4345] vm_dump.c:755
[0x7f4b613233e7]
/usr/local/lib/libruby.so.2.7(sigsegv+0x4b) [0x7f4b6144fccb] signal.c:946
/lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7f4b6102c730]
/lib/x86_64-linux-gnu/libc.so.6(0x7f4b60d6001c) [0x7f4b60d6001c]
/usr/local/lib/libruby.so.2.7(BSD_vfprintf+0x6fc) [0x7f4b6145232c] vsnprintf.c:1019
/usr/local/lib/libruby.so.2.7(ruby_vsnprintf+0x6f) [0x7f4b6145510f] sprintf.c:1022
/usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so(0x7f4b5930de60) [0x7f4b5930de60]
/usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so(0x7f4b593184ae) [0x7f4b593184ae]
/usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so(0x7f4b59318556) [0x7f4b59318556]
[0x7f4b614c3439]
[0x7f4b614dbebc]
/usr/local/lib/libruby.so.2.7(vm_call_method+0x55) [0x7f4b614dc655] vm_insnhelper.c:3026
[0x7f4b614ce872]
[0x7f4b614d438c]
/usr/local/lib/libruby.so.2.7(rb_ec_exec_node+0xaa) [0x7f4b61327dda] eval.c:278
/usr/local/lib/libruby.so.2.7(ruby_run_node+0x49) [0x7f4b6132d049] eval.c:336
/usr/local/bin/ruby(main+0x5b) [0x56102ae6c10b] ./main.c:50

-- Other runtime information -----------------------------------------------

* Loaded script: ./repro.rb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 ruby2_keywords.rb
    5 /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/encdb.so
    6 /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/trans/transdb.so
    7 /usr/local/lib/ruby/2.7.0/x86_64-linux/rbconfig.rb
    8 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/compatibility.rb
    9 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/defaults.rb
   10 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/deprecate.rb
   11 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/errors.rb
   12 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/version.rb
   13 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/requirement.rb
   14 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/platform.rb
   15 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/basic_specification.rb
   16 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/stub_specification.rb
   17 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/util.rb
   18 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/text.rb
   19 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/user_interaction.rb
   20 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/specification_policy.rb
   21 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/util/list.rb
   22 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb
   23 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/exceptions.rb
   24 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/bundler_version_finder.rb
   25 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/dependency.rb
   26 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_gem.rb
   27 /usr/local/lib/ruby/2.7.0/x86_64-linux/monitor.so
   28 /usr/local/lib/ruby/2.7.0/monitor.rb
   29 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb
   30 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_warn.rb
   31 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems.rb
   32 /usr/local/lib/ruby/2.7.0/x86_64-linux/pathname.so
   33 /usr/local/lib/ruby/2.7.0/pathname.rb
   34 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/version.rb
   35 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/constants.rb
   36 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb
   37 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/current_ruby.rb
   38 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/shared_helpers.rb
   39 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/fileutils/lib/fileutils.rb
   40 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendored_fileutils.rb
   41 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/errors.rb
   42 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/environment_preserver.rb
   43 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/plugin/api.rb
   44 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/plugin.rb
   45 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/source/git.rb
   46 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/source/installed.rb
   47 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/source/specific_file.rb
   48 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/source/local.rb
   49 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/source/lock.rb
   50 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/source/vendor.rb
   51 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/source.rb
   52 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/gem_helpers.rb
   53 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/match_platform.rb
   54 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/rubygems_ext.rb
   55 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/build_metadata.rb
   56 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler.rb
   57 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ui.rb
   58 /usr/local/lib/ruby/2.7.0/set.rb
   59 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb
   60 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
   61 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/error.rb
   62 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb
   63 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/nested_context.rb
   64 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
   65 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
   66 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/parser/option.rb
   67 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/parser/options.rb
   68 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/parser.rb
   69 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/shell.rb
   70 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
   71 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
   72 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/line_editor.rb
   73 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/util.rb
   74 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb
   75 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb
   76 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendored_thor.rb
   77 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ui/shell.rb
   78 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
   79 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/shell/color.rb
   80 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/ext/builder.rb
   81 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ui/rg_proxy.rb
   82 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/settings.rb
   83 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/yaml_serializer.rb
   84 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/feature_flag.rb
   85 /usr/local/lib/ruby/site_ruby/2.7.0/rubygems/path_support.rb
   86 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source.rb
   87 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/path.rb
   88 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/git.rb
   89 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/rubygems.rb
   90 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/lockfile_parser.rb
   91 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb
   92 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/dependency.rb
   93 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ruby_dsl.rb
   94 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/dsl.rb
   95 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source_list.rb
   96 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/metadata.rb
   97 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/version.rb
   98 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
   99 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
  100 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/common.rb
  101 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/generic.rb
  102 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/file.rb
  103 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/ftp.rb
  104 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/http.rb
  105 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/https.rb
  106 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/ldap.rb
  107 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/ldaps.rb
  108 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri/mailto.rb
  109 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/uri/lib/uri.rb
  110 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendored_uri.rb
  111 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ruby_version.rb
  112 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/lazy_specification.rb
  113 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/index.rb
  114 /usr/local/lib/ruby/2.7.0/tsort.rb
  115 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/spec_set.rb
  116 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb
  117 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb
  118 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb
  119 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb
  120 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb
  121 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
  122 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
  123 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
  124 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
  125 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb
  126 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb
  127 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb
  128 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb
  129 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
  130 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
  131 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb
  132 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb
  133 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
  134 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
  135 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb
  136 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/molinillo/lib/molinillo.rb
  137 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendored_molinillo.rb
  138 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/resolver/spec_group.rb
  139 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/resolver.rb
  140 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/gemspec.rb
  141 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb
  142 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/dep_proxy.rb
  143 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/remote_specification.rb
  144 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/stub_specification.rb
  145 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/endpoint_specification.rb
  146 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/setup.rb
  147 /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/protobuf/message_exts.rb
  148 /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so
  149 /usr/local/lib/ruby/2.7.0/forwardable/impl.rb
  150 /usr/local/lib/ruby/2.7.0/forwardable/version.rb
  151 /usr/local/lib/ruby/2.7.0/forwardable.rb
  152 /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/protobuf/repeated_field.rb
  153 /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/protobuf.rb

* Process memory map:

56102ae6b000-56102ae6c000 r--p 00000000 fe:01 2888245                    /usr/local/bin/ruby
56102ae6c000-56102ae6d000 r-xp 00001000 fe:01 2888245                    /usr/local/bin/ruby
56102ae6d000-56102ae6e000 r--p 00002000 fe:01 2888245                    /usr/local/bin/ruby
56102ae6e000-56102ae6f000 r--p 00002000 fe:01 2888245                    /usr/local/bin/ruby
56102ae6f000-56102ae70000 rw-p 00003000 fe:01 2888245                    /usr/local/bin/ruby
7f4b58766000-7f4b58924000 r--s 00000000 fe:01 2097479                    /lib/x86_64-linux-gnu/libc-2.28.so
7f4b58924000-7f4b58948000 r--s 00000000 fe:01 2097534                    /lib/x86_64-linux-gnu/libpthread-2.28.so
7f4b58948000-7f4b592d8000 r--s 00000000 fe:01 2888286                    /usr/local/lib/libruby.so.2.7.1
7f4b592d8000-7f4b59309000 r--s 00000000 fe:01 2888245                    /usr/local/bin/ruby
7f4b59309000-7f4b5930d000 r--p 00000000 fe:01 2414367                    /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so
7f4b5930d000-7f4b59334000 r-xp 00004000 fe:01 2414367                    /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so
7f4b59334000-7f4b5933e000 r--p 0002b000 fe:01 2414367                    /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so
7f4b5933e000-7f4b5933f000 r--p 00034000 fe:01 2414367                    /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so
7f4b5933f000-7f4b59340000 rw-p 00035000 fe:01 2414367                    /usr/local/bundle/gems/google-protobuf-3.15.0-x86_64-linux/lib/google/2.7/protobuf_c.so
7f4b59340000-7f4b5c340000 rw-p 00000000 00:00 0 
7f4b5c340000-7f4b5c341000 ---p 00000000 00:00 0 
7f4b5c341000-7f4b5c3e2000 rw-p 00000000 00:00 0 
7f4b5c3e2000-7f4b5c3e3000 ---p 00000000 00:00 0 
7f4b5c3e3000-7f4b5c484000 rw-p 00000000 00:00 0 
7f4b5c484000-7f4b5c485000 ---p 00000000 00:00 0 
7f4b5c485000-7f4b5c526000 rw-p 00000000 00:00 0 
7f4b5c526000-7f4b5c527000 ---p 00000000 00:00 0 
7f4b5c527000-7f4b5c5c8000 rw-p 00000000 00:00 0 
7f4b5c5c8000-7f4b5c5c9000 ---p 00000000 00:00 0 
7f4b5c5c9000-7f4b5c66a000 rw-p 00000000 00:00 0 
7f4b5c66a000-7f4b5c66b000 ---p 00000000 00:00 0 
7f4b5c66b000-7f4b5c70c000 rw-p 00000000 00:00 0 
7f4b5c70c000-7f4b5c70d000 ---p 00000000 00:00 0 
7f4b5c70d000-7f4b5c7ae000 rw-p 00000000 00:00 0 
7f4b5c7ae000-7f4b5c7af000 ---p 00000000 00:00 0 
7f4b5c7af000-7f4b5c850000 rw-p 00000000 00:00 0 
7f4b5c850000-7f4b5c851000 ---p 00000000 00:00 0 
7f4b5c851000-7f4b5c8f2000 rw-p 00000000 00:00 0 
7f4b5c8f2000-7f4b5c8f3000 ---p 00000000 00:00 0 
7f4b5c8f3000-7f4b5c994000 rw-p 00000000 00:00 0 
7f4b5c994000-7f4b5c995000 ---p 00000000 00:00 0 
7f4b5c995000-7f4b5ca36000 rw-p 00000000 00:00 0 
7f4b5ca36000-7f4b5ca37000 ---p 00000000 00:00 0 
7f4b5ca37000-7f4b5cad8000 rw-p 00000000 00:00 0 
7f4b5cad8000-7f4b5cad9000 ---p 00000000 00:00 0 
7f4b5cad9000-7f4b5cb7a000 rw-p 00000000 00:00 0 
7f4b5cb7a000-7f4b5cb7b000 ---p 00000000 00:00 0 
7f4b5cb7b000-7f4b5cc1c000 rw-p 00000000 00:00 0 
7f4b5cc1c000-7f4b5cc1d000 ---p 00000000 00:00 0 
7f4b5cc1d000-7f4b5ccbe000 rw-p 00000000 00:00 0 
7f4b5ccbe000-7f4b5ccbf000 ---p 00000000 00:00 0 
7f4b5ccbf000-7f4b5cd60000 rw-p 00000000 00:00 0 
7f4b5cd60000-7f4b5cd61000 ---p 00000000 00:00 0 
7f4b5cd61000-7f4b5ce02000 rw-p 00000000 00:00 0 
7f4b5ce02000-7f4b5ce03000 ---p 00000000 00:00 0 
7f4b5ce03000-7f4b5cea4000 rw-p 00000000 00:00 0 
7f4b5cea4000-7f4b5cea5000 ---p 00000000 00:00 0 
7f4b5cea5000-7f4b5cf46000 rw-p 00000000 00:00 0 
7f4b5cf46000-7f4b5cf47000 ---p 00000000 00:00 0 
7f4b5cf47000-7f4b5cfe8000 rw-p 00000000 00:00 0 
7f4b5cfe8000-7f4b5cfe9000 ---p 00000000 00:00 0 
7f4b5cfe9000-7f4b5d08a000 rw-p 00000000 00:00 0 
7f4b5d08a000-7f4b5d08b000 ---p 00000000 00:00 0 
7f4b5d08b000-7f4b5d12c000 rw-p 00000000 00:00 0 
7f4b5d12c000-7f4b5d12d000 ---p 00000000 00:00 0 
7f4b5d12d000-7f4b5d1ce000 rw-p 00000000 00:00 0 
7f4b5d1ce000-7f4b5d1cf000 ---p 00000000 00:00 0 
7f4b5d1cf000-7f4b5d270000 rw-p 00000000 00:00 0 
7f4b5d270000-7f4b5d271000 ---p 00000000 00:00 0 
7f4b5d271000-7f4b5d312000 rw-p 00000000 00:00 0 
7f4b5d312000-7f4b5d313000 ---p 00000000 00:00 0 
7f4b5d313000-7f4b5d3b4000 rw-p 00000000 00:00 0 
7f4b5d3b4000-7f4b5d3b5000 ---p 00000000 00:00 0 
7f4b5d3b5000-7f4b5d456000 rw-p 00000000 00:00 0 
7f4b5d456000-7f4b5d457000 ---p 00000000 00:00 0 
7f4b5d457000-7f4b5d4f8000 rw-p 00000000 00:00 0 
7f4b5d4f8000-7f4b5d4f9000 ---p 00000000 00:00 0 
7f4b5d4f9000-7f4b5d59a000 rw-p 00000000 00:00 0 
7f4b5d59a000-7f4b5d59b000 ---p 00000000 00:00 0 
7f4b5d59b000-7f4b5d63c000 rw-p 00000000 00:00 0 
7f4b5d63c000-7f4b5d63d000 ---p 00000000 00:00 0 
7f4b5d63d000-7f4b5d6de000 rw-p 00000000 00:00 0 
7f4b5d6de000-7f4b5d6df000 ---p 00000000 00:00 0 
7f4b5d6df000-7f4b5d780000 rw-p 00000000 00:00 0 
7f4b5d780000-7f4b60a00000 rw-p 00000000 00:00 0 
7f4b60a0e000-7f4b60a10000 r--p 00000000 fe:01 2889597                    /usr/local/lib/ruby/2.7.0/x86_64-linux/pathname.so
7f4b60a10000-7f4b60a15000 r-xp 00002000 fe:01 2889597                    /usr/local/lib/ruby/2.7.0/x86_64-linux/pathname.so
7f4b60a15000-7f4b60a17000 r--p 00007000 fe:01 2889597                    /usr/local/lib/ruby/2.7.0/x86_64-linux/pathname.so
7f4b60a17000-7f4b60a18000 r--p 00008000 fe:01 2889597                    /usr/local/lib/ruby/2.7.0/x86_64-linux/pathname.so
7f4b60a18000-7f4b60a19000 rw-p 00009000 fe:01 2889597                    /usr/local/lib/ruby/2.7.0/x86_64-linux/pathname.so
7f4b60a19000-7f4b60a1a000 r--p 00000000 fe:01 2889593                    /usr/local/lib/ruby/2.7.0/x86_64-linux/monitor.so
7f4b60a1a000-7f4b60a1b000 r-xp 00001000 fe:01 2889593                    /usr/local/lib/ruby/2.7.0/x86_64-linux/monitor.so
7f4b60a1b000-7f4b60a1c000 r--p 00002000 fe:01 2889593                    /usr/local/lib/ruby/2.7.0/x86_64-linux/monitor.so
7f4b60a1c000-7f4b60a1d000 r--p 00002000 fe:01 2889593                    /usr/local/lib/ruby/2.7.0/x86_64-linux/monitor.so
7f4b60a1d000-7f4b60a1e000 rw-p 00003000 fe:01 2889593                    /usr/local/lib/ruby/2.7.0/x86_64-linux/monitor.so
7f4b60a1e000-7f4b60a1f000 r--p 00000000 fe:01 2889566                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/trans/transdb.so
7f4b60a1f000-7f4b60a21000 r-xp 00001000 fe:01 2889566                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/trans/transdb.so
7f4b60a21000-7f4b60a22000 r--p 00003000 fe:01 2889566                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/trans/transdb.so
7f4b60a22000-7f4b60a23000 r--p 00003000 fe:01 2889566                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/trans/transdb.so
7f4b60a23000-7f4b60a24000 rw-p 00004000 fe:01 2889566                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/trans/transdb.so
7f4b60a24000-7f4b60a25000 r--p 00000000 fe:01 2889522                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/encdb.so
7f4b60a25000-7f4b60a26000 r-xp 00001000 fe:01 2889522                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/encdb.so
7f4b60a26000-7f4b60a27000 r--p 00002000 fe:01 2889522                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/encdb.so
7f4b60a27000-7f4b60a28000 r--p 00002000 fe:01 2889522                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/encdb.so
7f4b60a28000-7f4b60a29000 rw-p 00003000 fe:01 2889522                    /usr/local/lib/ruby/2.7.0/x86_64-linux/enc/encdb.so
7f4b60a29000-7f4b60a30000 r--s 00000000 fe:01 2098199                    /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
7f4b60a30000-7f4b60a62000 r--p 00000000 fe:01 2097927                    /usr/lib/locale/C.UTF-8/LC_CTYPE
7f4b60a62000-7f4b60a6a000 rw-p 00000000 00:00 0 
7f4b60a6a000-7f4b60a6d000 r--p 00000000 fe:01 2097495                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f4b60a6d000-7f4b60a7e000 r-xp 00003000 fe:01 2097495                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f4b60a7e000-7f4b60a81000 r--p 00014000 fe:01 2097495                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f4b60a81000-7f4b60a82000 ---p 00017000 fe:01 2097495                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f4b60a82000-7f4b60a83000 r--p 00017000 fe:01 2097495                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f4b60a83000-7f4b60a84000 rw-p 00018000 fe:01 2097495                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f4b60a84000-7f4b60b0d000 r--p 00000000 fe:01 2098245                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f4b60b0d000-7f4b60bb9000 r-xp 00089000 fe:01 2098245                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f4b60bb9000-7f4b60bf7000 r--p 00135000 fe:01 2098245                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f4b60bf7000-7f4b60bf8000 ---p 00173000 fe:01 2098245                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f4b60bf8000-7f4b60c02000 r--p 00173000 fe:01 2098245                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f4b60c02000-7f4b60c04000 rw-p 0017d000 fe:01 2098245                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f4b60c04000-7f4b60c08000 rw-p 00000000 00:00 0 
7f4b60c08000-7f4b60c2a000 r--p 00000000 fe:01 2097479                    /lib/x86_64-linux-gnu/libc-2.28.so
7f4b60c2a000-7f4b60d72000 r-xp 00022000 fe:01 2097479                    /lib/x86_64-linux-gnu/libc-2.28.so
7f4b60d72000-7f4b60dbe000 r--p 0016a000 fe:01 2097479                    /lib/x86_64-linux-gnu/libc-2.28.so
7f4b60dbe000-7f4b60dbf000 ---p 001b6000 fe:01 2097479                    /lib/x86_64-linux-gnu/libc-2.28.so
7f4b60dbf000-7f4b60dc3000 r--p 001b6000 fe:01 2097479                    /lib/x86_64-linux-gnu/libc-2.28.so
7f4b60dc3000-7f4b60dc5000 rw-p 001ba000 fe:01 2097479                    /lib/x86_64-linux-gnu/libc-2.28.so
7f4b60dc5000-7f4b60dc9000 rw-p 00000000 00:00 0 
7f4b60dc9000-7f4b60dd6000 r--p 00000000 fe:01 2097502                    /lib/x86_64-linux-gnu/libm-2.28.so
7f4b60dd6000-7f4b60e75000 r-xp 0000d000 fe:01 2097502                    /lib/x86_64-linux-gnu/libm-2.28.so
7f4b60e75000-7f4b60f4a000 r--p 000ac000 fe:01 2097502                    /lib/x86_64-linux-gnu/libm-2.28.so
7f4b60f4a000-7f4b60f4b000 r--p 00180000 fe:01 2097502                    /lib/x86_64-linux-gnu/libm-2.28.so
7f4b60f4b000-7f4b60f4c000 rw-p 00181000 fe:01 2097502                    /lib/x86_64-linux-gnu/libm-2.28.so
7f4b60f4c000-7f4b60f4d000 r--p 00000000 fe:01 2097485                    /lib/x86_64-linux-gnu/libcrypt-2.28.so
7f4b60f4d000-7f4b60f53000 r-xp 00001000 fe:01 2097485                    /lib/x86_64-linux-gnu/libcrypt-2.28.so
7f4b60f53000-7f4b60f55000 r--p 00007000 fe:01 2097485                    /lib/x86_64-linux-gnu/libcrypt-2.28.so
7f4b60f55000-7f4b60f56000 ---p 00009000 fe:01 2097485                    /lib/x86_64-linux-gnu/libcrypt-2.28.so
7f4b60f56000-7f4b60f57000 r--p 00009000 fe:01 2097485                    /lib/x86_64-linux-gnu/libcrypt-2.28.so
7f4b60f57000-7f4b60f58000 rw-p 0000a000 fe:01 2097485                    /lib/x86_64-linux-gnu/libcrypt-2.28.so
7f4b60f58000-7f4b60f86000 rw-p 00000000 00:00 0 
7f4b60f86000-7f4b60f87000 r--p 00000000 fe:01 2097487                    /lib/x86_64-linux-gnu/libdl-2.28.so
7f4b60f87000-7f4b60f88000 r-xp 00001000 fe:01 2097487                    /lib/x86_64-linux-gnu/libdl-2.28.so
7f4b60f88000-7f4b60f89000 r--p 00002000 fe:01 2097487                    /lib/x86_64-linux-gnu/libdl-2.28.so
7f4b60f89000-7f4b60f8a000 r--p 00002000 fe:01 2097487                    /lib/x86_64-linux-gnu/libdl-2.28.so
7f4b60f8a000-7f4b60f8b000 rw-p 00003000 fe:01 2097487                    /lib/x86_64-linux-gnu/libdl-2.28.so
7f4b60f8b000-7f4b60f8d000 rw-p 00000000 00:00 0 
7f4b60f8d000-7f4b60f98000 r--p 00000000 fe:01 2098222                    /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f4b60f98000-7f4b60ff6000 r-xp 0000b000 fe:01 2098222                    /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f4b60ff6000-7f4b6100d000 r--p 00069000 fe:01 2098222                    /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f4b6100d000-7f4b6100e000 ---p 00080000 fe:01 2098222                    /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f4b6100e000-7f4b6100f000 r--p 00080000 fe:01 2098222                    /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f4b6100f000-7f4b61010000 rw-p 00081000 fe:01 2098222                    /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f4b61010000-7f4b61012000 r--p 00000000 fe:01 2097538                    /lib/x86_64-linux-gnu/librt-2.28.so
7f4b61012000-7f4b61016000 r-xp 00002000 fe:01 2097538                    /lib/x86_64-linux-gnu/librt-2.28.so
7f4b61016000-7f4b61018000 r--p 00006000 fe:01 2097538                    /lib/x86_64-linux-gnu/librt-2.28.so
7f4b61018000-7f4b61019000 r--p 00007000 fe:01 2097538                    /lib/x86_64-linux-gnu/librt-2.28.so
7f4b61019000-7f4b6101a000 rw-p 00008000 fe:01 2097538                    /lib/x86_64-linux-gnu/librt-2.28.so
7f4b6101a000-7f4b61020000 r--p 00000000 fe:01 2097534                    /lib/x86_64-linux-gnu/libpthread-2.28.so
7f4b61020000-7f4b6102f000 r-xp 00006000 fe:01 2097534                    /lib/x86_64-linux-gnu/libpthread-2.28.so
7f4b6102f000-7f4b61035000 r--p 00015000 fe:01 2097534                    /lib/x86_64-linux-gnu/libpthread-2.28.so
7f4b61035000-7f4b61036000 r--p 0001a000 fe:01 2097534                    /lib/x86_64-linux-gnu/libpthread-2.28.so
7f4b61036000-7f4b61037000 rw-p 0001b000 fe:01 2097534                    /lib/x86_64-linux-gnu/libpthread-2.28.so
7f4b61037000-7f4b6103b000 rw-p 00000000 00:00 0 
7f4b6103b000-7f4b61057000 r-xp 00000000 fe:01 2097559                    /lib/x86_64-linux-gnu/libz.so.1.2.11
7f4b61057000-7f4b61257000 ---p 0001c000 fe:01 2097559                    /lib/x86_64-linux-gnu/libz.so.1.2.11
7f4b61257000-7f4b61258000 r--p 0001c000 fe:01 2097559                    /lib/x86_64-linux-gnu/libz.so.1.2.11
7f4b61258000-7f4b61259000 rw-p 0001d000 fe:01 2097559                    /lib/x86_64-linux-gnu/libz.so.1.2.11
7f4b6125d000-7f4b6128a000 r--p 00000000 fe:01 2888286                    /usr/local/lib/libruby.so.2.7.1
7f4b6128a000-7f4b614f0000 r-xp 0002d000 fe:01 2888286                    /usr/local/lib/libruby.so.2.7.1
7f4b614f0000-7f4b615e4000 r--p 00293000 fe:01 2888286                    /usr/local/lib/libruby.so.2.7.1
7f4b615e4000-7f4b615e5000 ---p 00387000 fe:01 2888286                    /usr/local/lib/libruby.so.2.7.1
7f4b615e5000-7f4b615eb000 r--p 00387000 fe:01 2888286                    /usr/local/lib/libruby.so.2.7.1
7f4b615eb000-7f4b615ee000 rw-p 0038d000 fe:01 2888286                    /usr/local/lib/libruby.so.2.7.1
7f4b615ee000-7f4b61609000 rw-p 00000000 00:00 0 
7f4b61609000-7f4b6160f000 r--p 00000000 fe:01 3015381                    /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
7f4b6160f000-7f4b61692000 r-xp 00006000 fe:01 3015381                    /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
7f4b61692000-7f4b616a2000 r--p 00089000 fe:01 3015381                    /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
7f4b616a2000-7f4b616a7000 r--p 00098000 fe:01 3015381                    /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
7f4b616a7000-7f4b616a8000 rw-p 0009d000 fe:01 3015381                    /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
7f4b616a8000-7f4b618ca000 rw-p 00000000 00:00 0 
7f4b618ca000-7f4b618cb000 r--p 00000000 fe:01 2097465                    /lib/x86_64-linux-gnu/ld-2.28.so
7f4b618cb000-7f4b618e9000 r-xp 00001000 fe:01 2097465                    /lib/x86_64-linux-gnu/ld-2.28.so
7f4b618e9000-7f4b618f1000 r--p 0001f000 fe:01 2097465                    /lib/x86_64-linux-gnu/ld-2.28.so
7f4b618f1000-7f4b618f2000 r--p 00026000 fe:01 2097465                    /lib/x86_64-linux-gnu/ld-2.28.so
7f4b618f2000-7f4b618f3000 rw-p 00027000 fe:01 2097465                    /lib/x86_64-linux-gnu/ld-2.28.so
7f4b618f3000-7f4b618f4000 rw-p 00000000 00:00 0 
7ffda6801000-7ffda7000000 rw-p 00000000 00:00 0                          [stack]
7ffda7047000-7ffda704a000 r--p 00000000 00:00 0                          [vvar]
7ffda704a000-7ffda704c000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]


Aborted
@rodzyn
Copy link

rodzyn commented Feb 19, 2021

Thanks for reporting, I have experienced the same issue

@haberman
Copy link
Member

Thanks for the report and the great repro. I have a fix here: #8313

@tmtrademarked
Copy link

After updating from 3.14.0 to 3.15.3, we started seeing a crash that appears related, even with the fix provided in the above PR. If the Inners field contains nil, you can still get a segfault. (In 3.14.0, this does not happen)

I've modified the repro script here slightly to demonstrate the failure mode:

require 'google/protobuf'

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file("inner.proto", :syntax => :proto3) do
    add_message "Inner" do
      # Removing either of these fixes the segfault.
      optional :foo, :string, 1
      optional :bar, :string, 2
    end
  end
end

Inner = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Inner").msgclass

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file("outer.proto", :syntax => :proto3) do
    add_message "Outer" do
      repeated :inners, :message, 1, "Inner"
    end
  end
end

Outer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Outer").msgclass

outer_proto = Outer.new(
  inners: [nil]
)
puts outer_proto

With 3.14.0, I get the following output:

tom:branch (master *)$ bundle exec ruby --disable-did_you_mean ./repro.rb 
<Outer: inners: [nil]>

With 3.15.3, I get a segfault. I don't think that's quite what the intended behavior is, right?

@haberman
Copy link
Member

haberman commented Mar 1, 2021

Thanks for the report, I've pasted your message into a new issue as this is a different bug, requiring a different fix: #8359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants