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 with nested msgs #502

Closed
skippy opened this issue Jun 16, 2015 · 7 comments
Closed

Ruby: SegFault with nested msgs #502

skippy opened this issue Jun 16, 2015 · 7 comments

Comments

@skippy
Copy link
Contributor

skippy commented Jun 16, 2015

hey folks,

the issue crops up in this PR: #387. IT doesn't exist before.

require 'google/protobuf'

pool = Google::Protobuf::DescriptorPool.new
pool.build do
  add_message "Source" do
    optional :system,        :string,          1
    optional :uri,           :string,          2
    optional :sourced_at,    :string,          3
    optional :updated_at,    :string,          4
    optional :raw_data,      :string,          5
    optional :raw_data_type, :string,          6
    optional :primary,       :bool,            7
    map      :meta,          :string, :string, 8
  end

  add_message "Location" do
    repeated :address,        :string,  3
    optional :city,           :string,  4
    optional :state,          :string,  5
    optional :postal_code,    :string,  6
    optional :country_code,   :string,  7
    optional :lat,            :double,  8
    optional :lng,            :double,  9
    optional :updated_at,     :string,  10
    repeated :sources,        :message, 11, "Source"
  end

  add_message "Business" do
    optional :name,          :string,   1
    optional :location,      :message,  2, "Location"
  end
end
Source = pool.lookup("Source").msgclass
Location = pool.lookup("Location").msgclass
Business = pool.lookup("Business").msgclass



location = Location.new address: ["1234 KING STREET", "SUITE 300"], city: 'PORTLAND', state: 'OR', postal_code: '97213', country_code: 'US'
location.sources << Source.new(system: 'county_db', uri: "csv://OR/pdx/country_registrar/1588667638", sourced_at: "2015-06-01", updated_at: "2014-05-29")
location.sources << Source.new(system: 'county_db', uri: "csv://OR/pdx/country_registrar/1588667638", sourced_at: "2015-06-01", updated_at: "2014-05-29")

business = Business.new name: 'Super Business'
business.location = location
Business.encode(business)

I can recreate it in ruby 2.1.6 and 2.2.0.

A few things I've noticed:

  • if only one source is added, it doesn't segfault
  • if the URI attribute within source is not set, it doesn't segfault.

I suspect this has to do with bytesize, that once the msg gets beyond a certain size, and it is nested, it fails.

Thoughts?

@haberman
Copy link
Member

Thanks for the report, and sorry for the bug. I have a hunch about what's going on. It's almost certainly a bug in upb, but should be easy to fix. I'll take a look.

@skippy
Copy link
Contributor Author

skippy commented Jun 17, 2015

Hey @haberman,
upb is a bit of a mystery to me at the moment. Thanks for your help on this one.

@Andrew-EP
Copy link

Hi @haberman , I have similar problem, is it expected to be fixed soon?

@haberman
Copy link
Member

I think this will be fixed by this PR that I just submitted: protocolbuffers/upb#30

@haberman
Copy link
Member

Sorry for the delay on this, the Travis build for the fix has been stuck in the queue all day long (6 hours).

@haberman
Copy link
Member

Fixed in #530

@skippy
Copy link
Contributor Author

skippy commented Jul 3, 2015

thanks!!

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

3 participants