Giter VIP home page Giter VIP logo

protobuf's Introduction

protobuf's People

Contributors

abrandoned avatar akihiro17 avatar aogail avatar bbonifield avatar bdferris avatar belison avatar brianstien avatar byroot avatar drcapulet avatar embark avatar film42 avatar filterfish avatar jhump avatar johnnyt avatar liveh2o avatar localshred avatar michaelxavier avatar minond avatar mix86 avatar mmmries avatar mvz avatar nerdrew avatar onethirtyfive avatar quixoten avatar rkushnir avatar shanna avatar skippy avatar tamird avatar tdeo avatar zachmargolis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protobuf's Issues

please update em to ~> 1.0.0.beta.1

There are some known problems in 1.8.x with em 0.12.0, em ~> 1.0.0.beta.1 not.

But I don't know whether the rpc server is compitable with em 1.0.0...

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

There is even a License Finder to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.

How did I find you?

I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for missing ones as a public service :)
https://gist.github.com/bf4/5952053#file-license_issue-rb-L13 So far it's going pretty well

Recommended method for adding new connectors?

A system I'm interfacing with encodes its socket level protocol as a four byte transaction id, a four byte message length, and then the message. What is the best way for me to add a new connector? Fork, add and send a PR or is there a programmatic way it should be done?

Can't call field#set with an array

When calling #set on a field, passing an array results in a TypeError exception ("can't convert Array into String").

Consider the following:

# protobuf definition
message Hello {
  repeated string world
}
message = Hello.new # initialize a new protobuf message
field = message.get_field(:world) # get the field to set
field.set(message, [ 'hello' ]) # boom!

At first glance, the code for #set seems like it should work, but it doesn't. The problem seems to be the decode call in lib/protobuf/message/field.rb, line 90.

I was able to get around it by simply calling the field with #method directly, but it would be nice to use this function.

Let me know if you have any questions.

-AH

"Nested Extensions" pattern results in Protobuf::DuplicateFieldNameError

When trying to implement the "nested extensions" polymorphism pattern described here the following Protobuf::DuplicateFieldNameError error results:

/Users/trobinson/.rvm/gems/ruby-2.0.0-p481/gems/protobuf-3.0.4/lib/protobuf/message/fields.rb:115:in `raise_if_name_collision': Field name animal has already been used in "MyProject::Rpc::Animal". (Protobuf::DuplicateFieldNameError)
  from /Users/trobinson/.rvm/gems/ruby-2.0.0-p481/gems/protobuf-3.0.4/lib/protobuf/message/fields.rb:94:in `define_field'
  from /Users/trobinson/.rvm/gems/ruby-2.0.0-p481/gems/protobuf-3.0.4/lib/protobuf/message/fields.rb:34:in `required'
  from /Users/trobinson/git/myproject/lib/myproject/rpc/test.pb.rb:40:in `<class:Animal>'
  from /Users/trobinson/git/myproject/lib/myproject/rpc/test.pb.rb:35:in `<module:Rpc>'
  from /Users/trobinson/git/myproject/lib/myproject/rpc/test.pb.rb:8:in `<module:MyProject>'
  from /Users/trobinson/git/myproject/lib/myproject/rpc/test.pb.rb:7:in `<top (required)>'
  from /Users/trobinson/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /Users/trobinson/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from nested-test.rb:4:in `<main>'

Here is the .proto I'm using:


message Animal {
  extensions 100 to max;

  enum Type {
    Cat = 1;
    Dog = 2;
  }

  required Type type = 1;
}

message Cat {
  extend Animal {
    required Cat animal = 100; // Unique Animal extension number
  }

  // These fields can use the full number range.
  optional bool declawed = 1;
}

message Dog {
  extend Animal {
    required Dog animal = 101; // Unique Animal extension number
  }

  // These fields can use the full number range.
  optional uint32 bones_buried = 1;
}

#inspect is blank when the message is empty

If you have a proto message that has only repeated or optional fields, if those fields are empty, calling #inspect prints a blank line. My expectation would be that it would print a hash of the fields with nil values when they are optional and empty arrays when they are repeated.

Missed protobuf/message/service.rb?

Bundle protobuf in my rails application and get this:

cannot load such file -- protobuf/message/service

My *.pb.rb files were generated by rprotoc. Wrong generation?

underscore_separated message names are constantized inconsistently

(related to #81) If a .proto contains underscore_separated message names, the generator capitalizes their use, but not their declaration.

  • When simple_mail is used in mail_list, it tries to use Simple_Mail, which doesn't exist.
  • Also, ruby chokes on the uncapitalized class names: SyntaxError: .../constantizing.pb.rb:10: class/module name must be CONSTANT

source (https://gist.github.com/nolanamy/5296526)

message simple_mail
{
    optional string body = 1;
}

message mail_list
{
    repeated simple_mail simple_mails = 1;
}

generates (https://gist.github.com/nolanamy/5296532)

##
# This file is auto-generated. DO NOT EDIT!
#
require 'protobuf/message'


##
# Message Classes
#
class simple_mail < ::Protobuf::Message; end
class mail_list < ::Protobuf::Message; end

##
# Message Fields
#
class simple_mail
  optional ::Protobuf::Field::StringField, :body, 1
end

class mail_list
  repeated ::Simple_Mail, :simple_mails, 1
end

Compiler can't find shared object file for JRuby

Using Jruby-1.7.4 and protobuf 2.7.10 I'm getting a shared object missing error when trying to compile:

bundle exec rprotoc measurement.proto --ruby_out ../lib/datacube/messages
    Cannot locate shared object to plugin to protocol buffers generator.
    Thought the file would be located at /home/michael/.rvm/gems/jruby-1.7.4/gems/protobuf-2.7.10-java/lib/ruby_generator.so

    If you are running on Windows you should compile protocol buffer
    definitions on another VM and then use those definitions locally.

    Only the compiler is restricted by this.  The definitions should work without issue.

If I symlink the shared object file built using MRI into that directory in JRuby it seems to work OK, but that of course isn't a great solution if this code is going to be distributed about, especially since there's a specific jruby version of protobuf. Any idea why that file doesn't get generated?

Thanks!

Uninitialized constant Protobuf::Enum (NameError)

I've got a basic .proto file and generated classes using rprotoc.

When I try to require the message.pb.rb, it throws an exception:

.../lib/ruby/gems/2.0.0/gems/protobuf-2.7.11/lib/protobuf/rpc/rpc.pb.rb:11:in '<module:Socketrpc>': uninitialized constant Protobuf::Enum (NameError)

The proto file is:

package foo;
message Command {
  enum CommandType {
    SAY_HELLO = 0;
  }
  required CommandType type = 1;
}

The generated output is:

##
# This file is auto-generated. DO NOT EDIT!
#
require 'protobuf/message'

module Foo

  ##
  # Message Classes
  #
  class Command < ::Protobuf::Message
    class CommandType < ::Protobuf::Enum
      define :SAY_HELLO, 0
    end

  end

  ##
  # Message Fields
  #
  class Command
    required ::Foo::Command::CommandType, :type, 1
  end


end

uninitialized constant Protobuf::VERSION

Starting with a clean install of protobuf(1.0.0) and a protobuf definition file, an error is thrown during compilation of the .proto file:

$ mkdir gtfs
$ cat Gemfile
source :rubygems
gem 'protobuf'
$ bundle install --path gems --binstubs
Fetching source index for http://rubygems.org/
Installing eventmachine (0.12.10) with native extensions 
Installing protobuf (1.0.0) 
Using bundler (1.0.21) 
Your bundle is complete! It was installed into ./gems
$ wget http://code.google.com/transit/realtime/proto/gtfs-realtime.proto
2011-12-07 09:47:28 (317 KB/s) - `gtfs-realtime.proto' saved [23073]
$ ./bin/rprotoc gtfs-realtime.proto -o ./lib
/home/donp/Documents/Code/icecondor/gtfs/gems/ruby/1.9.1/gems/protobuf-1.0.0/bin/rprotoc:25:in `<top (required)>': uninitialized constant Protobuf::VERSION (NameError)
    from ./bin/rprotoc:16:in `load'
    from ./bin/rprotoc:16:in `<main>'

Message.fields contains a nil value

When inspecting the fields of compiled protobuf message class, the first value being returned is nil:

1.9.2p290 :004 > Tag.fields
 => [nil, optional Protobuf::Field::Int64Field id = 1 , optional Protobuf::Field::StringField guid = 2 , optional Protobuf::Field::StringField name = 3 , optional Protobuf::Field::Int64Field revision = 4 , optional Protobuf::Field::StringField external_id = 5 , repeated Atlas::Error errors = 6 , optional Protobuf::Field::Int32Field status_code = 7 , optional Protobuf::Field::BoolField _association_destroyed = 8 , optional Protobuf::Field::StringField user_guid = 9 ] 

I verified that this is the case with several different messages.

Assigning a symbol to a string field is broken in 3.0.0.rc1

This is trivial to reproduce:

$ bx rake console
[1] pry(main)> Test::ResourceFindRequest.new(:widgets => ["foo"])
=> {:widgets=>["foo"]}
[2] pry(main)> Test::ResourceFindRequest.new(:widgets => [:foo])
TypeError: Cannot set field : widgets to value : foo
from /code/src/gems/protobuf/lib/protobuf/field/bytes_field.rb:29:in `acceptable?'

imports from imported proto files fail on loading dependancy

I am testing out using ruby protobuf for some code, the google protobuf implementation is ok with this type of nesting in fact it is required for message reuse. Seems like it should be a simple thing to fix with the import statement and it's resolution path. Reproducible with:

gem protobuf (1.1.3)
ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

test/TestMessage.proto

package com.test;
option java_outer_classname = "Test";

import "TestService.proto";
import "TestMessageResponse.proto";

message TestMessage {
optional TestService svc = 1;
optional TestMessageResponse res = 2;
}

test/TestService.proto

package com.test;

option java_outer_classname = "SVC";

message TestService {
optional string name = 1;
}

test/TestMessageResponse.proto

package com.test;

option java_outer_classname = "Res";

import "TestService.proto";

message TestMessageResponse {
optional string message = 1;
optional TestService svc = 2;
}

rprotoc -p test/ test/TestMessage.proto test/TestService.proto test/TestMessageResponse.proto
wrote ./com/test/TestService.pb.rb
wrote ./com/test/TestService.pb.rb
Error creating file ./TestMessageResponse.pb.rb
cannot load such file -- TestService.pb

with protoc from libprotoc 2.4.1

protoc --cpp_out=. --java_out=. --python_out=. --proto_path=test/ test/TestMessage.proto test/TestService.proto test/TestMessageResponse.proto

nothing to stdout all files generated as expected...

Thoughts? I am using zeromq for RPC and other work so I don't need the RPC functions thus the service in this test example doesn't have anything to do with protobuf RPC services.

Thanks,
Leif

get wrong when I change to old google-protobuf version 2.3.0

I need using old version of google-protobuf because my server must connect to a thirdparty server that using google-protobuf 2.3.0

ubuntu. ruby1.9.3 rails3.2
I change google-protobuf to 2.3.0 by http://sumitshresthatech.blogspot.hk/2012/03/installing-protocol-buffer-230-in-newer.html
copy to here
sudo apt-get remove libprotobuf* (* is version you may be having eg. 5, 7, etc)
sudo apt-get remove protobuf-compiler
sudo apt-get remove python-protobuf
sudo apt-get install g++ # if you don't have g++ installed

download protocol buffer

wget your-protocol-bufer.tar.gz
tar xvf your-protocol-bufer.tar.gz
cd protobuf-2.3.0
./configure
make
make check
sudo make install
cd python
sudo python setup.py install
sudo ldconfig
protoc --version
libprotoc 2.3.0

Then when I use gem-protobuf 2.7.10.
get error:
/home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf/rpc/rpc.pb.rb:11:in <module:Socketrpc>': uninitialized constant Protobuf::Enum (NameError) from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf/rpc/rpc.pb.rb:7:inmodule:Protobuf'
from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf/rpc/rpc.pb.rb:6:in <top (required)>' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:inrequire'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in require' from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf/rpc/error.rb:1:in<top (required)>'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in require' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:inrequire'
from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf/rpc/client.rb:4:in <top (required)>' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:inrequire'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in require' from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf.rb:86:in<top (required)>'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in require' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:inrequire'
from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf/field/base_field.rb:1:in <top (required)>' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:inrequire'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in require' from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf/field.rb:1:in<top (required)>'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in require' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:inrequire'
from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/protobuf-2.7.10/lib/protobuf/message.rb:2:in <top (required)>' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:inrequire'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in rescue in require' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:inrequire'
from /home/zyfire/work/eastrun/lib/protobuf/ks_gm.pb.rb:4:in <top (required)>' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' from /home/zyfire/work/eastrun/lib/game_interactive/recharge_game_point.rb:1:in<top (required)>'
from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' from /home/zyfire/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from /home/zyfire/work/eastrun/spec/lib/recharge_game_point_spec.rb:3:in <top (required)>' from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:inload'
from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in block in load_spec_files' from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:ineach'
from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in load_spec_files' from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:inrun'
from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in run' from /home/zyfire/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:inblock in autorun'

How I can use an old verison of google-protobuf? Maybe I ignore something.
Is there any document about old version?

thanks.

Potential vulnerability reading varints

The way varints are currently being read could potentially provide an attack vector by sending huge varints. I think Google limits them to 64 bits in their code. If you take a look at their CodedInputStream you'll see a ReadVarint32 and ReadVarint64, but not an open-ended ReadVarint. This may be because they have to read them into fixed types, but it's worth considering limiting it.

protobuf-2.7.3/bin/rprotoc:55: [BUG] Segmentation fault

Running a simple command:
rprotoc data/realtime-bidding.proto --ruby_out ./lib

I get this seg fault:

/Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/protobuf-2.7.3/bin/rprotoc:55: [BUG] Segmentation fault
ruby 1.9.3p155 (2012-03-03 revision 34878) [x86_64-darwin11.2.0]

-- Control frame information -----------------------------------------------
c:0008 p:---- s:0027 b:0027 l:000026 d:000026 CFUNC  :_rprotoc_extern
c:0007 p:0147 s:0022 b:0022 l:000021 d:000021 METHOD /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/protobuf-2.7.3/bin/rprotoc:55
c:0006 p:0307 s:0016 b:0016 l:000015 d:000015 TOP    /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/protobuf-2.7.3/bin/rprotoc:62
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC  :load
c:0003 p:0127 s:0007 b:0007 l:002618 d:0025d0 EVAL   /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/bin/rprotoc:19
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:002618 d:002618 TOP   

-- Ruby level backtrace information ----------------------------------------
/Users/exampleuser/.rvm/gems/ruby-1.9.3-head/bin/rprotoc:19:in `'
/Users/exampleuser/.rvm/gems/ruby-1.9.3-head/bin/rprotoc:19:in `load'
/Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/protobuf-2.7.3/bin/rprotoc:62:in `'
/Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/protobuf-2.7.3/bin/rprotoc:55:in `compile_proto'
/Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/protobuf-2.7.3/bin/rprotoc:55:in `_rprotoc_extern'

-- C level backtrace information -------------------------------------------

   See Crash Report log file under ~/Library/Logs/CrashReporter or
   /Library/Logs/CrashReporter, for the more detail of.

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

* Loaded script: /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/bin/rprotoc

* Loaded features:

    0 enumerator.so
    1 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/x86_64-darwin11.2.0/enc/encdb.bundle
    2 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/x86_64-darwin11.2.0/enc/trans/transdb.bundle
    3 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/defaults.rb
    4 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/x86_64-darwin11.2.0/rbconfig.rb
    5 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb
    6 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/exceptions.rb
    7 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
    8 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems.rb
    9 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/version.rb
   10 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb
   11 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb
   12 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/platform.rb
   13 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb
   14 /Users/exampleuser/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/path_support.rb
   15 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi_c.bundle
   16 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/platform.rb
   17 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/types.rb
   18 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/library.rb
   19 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/errno.rb
   20 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/pointer.rb
   21 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/memorypointer.rb
   22 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/struct_layout_builder.rb
   23 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/struct.rb
   24 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/union.rb
   25 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/managedstruct.rb
   26 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/callback.rb
   27 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/io.rb
   28 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/autopointer.rb
   29 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/variadic.rb
   30 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/enum.rb
   31 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi/ffi.rb
   32 /Users/exampleuser/.rvm/gems/ruby-1.9.3-head/gems/ffi-1.4.0/lib/ffi.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap: 6

The .proto file is supplied by Google:

// Copyright 2012 Google Inc. All Rights Reserved.

// This is the message that Google uses to request bids.  A single BidRequest
// includes all applicable ad slots from a single impression.
//
message BidRequest {
  // This is deprecated.  Please ignore.
  optional int32 DEPRECATED_protocol_version = 1;

  // Unique request id generated by Google.  This is 16 bytes long.
  required bytes id = 2;

  // This is deprecated.  Please use the CLICK_URL macro in the HTML snippet
  // instead.
  optional string DEPRECATED_click_tracking_url = 3;

  // -----------------------------------------------------------
  // This section lists information that we know about the user.

  // The first 3 bytes of the IP address in network byte order for IPv4, or the
  // first 6 bytes for IPv6.  Note that the number and position of the bytes
  // included from IPv6 addresses may change later.
  optional bytes ip = 4;

  // This is deprecated.  Please use google_user_id instead.
  optional uint64 DEPRECATED_cookie = 5;

  // This is deprecated.  Please use google_user_id instead.
  optional bytes DEPRECATED_hashed_cookie = 16;

  // The Google ID for the user as described in the documentation for the cookie
  // matching service.  This field is the unpadded web-safe base64 encoded
  // version of a binary cookie id. See the "Base 64 Encoding with URL and
  // Filename Safe Alphabet" section in RFC 3548 for encoding details.  This
  // field is the same as the Google ID returned by the cookie matching service.
  optional string google_user_id = 21;

  // The version number of the google_user_id.  We may sometimes change the
  // mapping from cookie to google_user_id.  In this case the version will be
  // incremented.
  optional uint32 cookie_version = 20;

  // The time in seconds since the google_user_id was created.
  optional int32 cookie_age_seconds = 31;

  // Match data stored for this google_user_id through the cookie matching
  // service.  If a match exists, then this field holds the decoded data that
  // was passed in the google_hm parameter.
  optional bytes hosted_match_data = 37;

  // A string that identifies the browser and type of device that sent the
  // request.
  optional string user_agent = 6;

  // These fields are deprecated. Please use the geo_criteria_id instead.
  optional string DEPRECATED_country = 7;
  optional string DEPRECATED_region = 8;
  optional string DEPRECATED_city = 9;
  optional int32 DEPRECATED_metro = 10;

  // Geo information.  These use a subset of the codes used in the AdWords API.
  // The documentation for the codes is at
  // https://developers.google.com/adwords/api/docs/appendix/geotargeting
  //
  // The geo_criteria_id field supercedes the legacy country, region, city, and
  // metro fields.
  optional int32 geo_criteria_id = 39;

  // Detected postal code of the appropriate type for the country (e.g. zip code
  // if the country is "US").  The postal_code_prefix field is set when accuracy
  // is too low to imply a full code, otherwise the postal_code field is set.
  optional string postal_code = 33;
  optional string postal_code_prefix = 34;

  // The offset of the user's time from GMT in minutes.  For example, GMT+10 is
  // timezone_offset = 600.
  optional int32 timezone_offset = 25;

  // List of detected user verticals.  Currently unused.
  repeated int32 user_vertical = 30 [packed=true];

  // Audience-targeting list to which the user has been added. See the Buyer UI
  // Help topics on remarketing, where it is called a remarketing list.
  message UserList {
    // The user list id.
    optional int64 id = 1;

    // The time in seconds since the user was added to the list.
    optional int32 age_seconds = 2;
  }
  repeated UserList user_list = 32;

  // -----------------------------------------------------------
  // This section lists information that we know about the web page or mobile
  // application where the impression originates.

  // This is deprecated. Please use seller_network_id instead.
  optional string DEPRECATED_seller_network = 22;

  // The seller network id.  See seller-network-ids.txt file in the technical
  // documentation for a list of ids.  This is only set if the site is not
  // anonymous and the publisher allows site targeting.
  optional int32 seller_network_id = 41;

  // The URL of the page with parameters removed.  This is only set if the site
  // is not anonymous and the publisher allows site targeting.  You can use
  // anonymous_id for targeting if the inventory is anonymous.  Otherwise, use
  // detected_vertical's.
  optional string url = 11;

  // An id for the domain of the page.  This is set when the inventory is
  // anonymous.
  optional string anonymous_id = 19;

  // The two-letter code for the language of the page.  The documentation for
  // the codes is at
  // https://developers.google.com/adwords/api/docs/appendix/languagecodes
  optional string detected_language = 12;

  // One or more detected verticals for the page as determined by Google.
  //
  message Vertical {
    // The vertical id.  See the publisher-verticals.txt file in the technical
    // documentation for a list of ids.
    required int32 id = 1;

    // Weight for this vertical, in the (0.0, 1.0] range.  More relevant
    // verticals have higher weights.
    required float weight = 2;
  }

  // Unordered list of detected content verticals.  See the
  // publisher-verticals.txt file in the technical documentation for a list of
  // ids.
  repeated Vertical detected_vertical = 13;

  // The dictionary version used in the detected_vertical field.  This is
  // currently always "2".
  optional int32 vertical_dictionary_version = 24;

  // List of detected content labels.  See content-labels.txt file in the
  // technical documentation for a list of ids.
  repeated int32 detected_content_label = 26 [packed=true];

  // Site lists that apply to this publisher.  See site-lists.txt in the
  // technical documentation for a list of ids.
  repeated int32 site_list_id = 36;

  // Additional key-value attributes.  Currently unused.
  message KeyValue {
    optional string key = 1;
    optional string value = 2;
  }
  repeated KeyValue key_value = 38;

  // Information for ad queries coming from mobile devices.  A mobile device is
  // either a smartphone or a tablet.  This is present for ad queries both from
  // mobile devices browsing the web and from mobile apps.
  //
  message Mobile {
    // This is deprecated.  Please use app_id instead.
    optional string DEPRECATED_app_name = 1;

    // This is deprecated.  Please do not use.
    optional string DEPRECATED_company_name = 2;

    // The platform of the mobile device.  Examples: android, iphone, palm
    optional string platform = 3;

    // The brand of the mobile device, e.g. Nokia, Samsung.
    optional string brand = 12;

    // The model of the mobile device, e.g. N70, Galaxy.
    optional string model = 13;

    // This message contains the OS version of the platform.  For instance, for
    // Android 2.1, os_version_major=2, os_version_minor=1, and os_version_micro
    // will remain unpopulated.  For iPhone 3.3.1, os_version_major=3,
    // os_version_minor=3, and os_version_micro=1.
    message DeviceOsVersion {
      optional int32 os_version_major = 1;
      optional int32 os_version_minor = 2;
      optional int32 os_version_micro = 3;
    }

    // The OS version; e.g. 2.1 for Android 2.1, or 3.3.1 for iOS 3.3.1.
    optional DeviceOsVersion os_version = 14;

    // The name of the mobile carrier when the mobile device is connected to the
    // internet via the carrier (as opposed to via WiFi).  Example: t-mobile
    optional string carrier_name = 4;

    // The country the mobile carrier operates in when the mobile device is
    // connected to the internet via the carrier (as opposed to via WiFi).
    // Example: jp
    optional string carrier_country = 5;

    // If true, then this request is from a mobile application. Will always be
    // true when app_id is set.  May also be true for anonymous inventory, in
    // which case anonymous_id will be set.
    optional bool is_app = 7 [default = false];

    // The identifier of the mobile app when this ad query comes from a mobile
    // app.  If the app was downloaded from the Apple iTunes app store, then
    // this is the app-store id.  For Android devices, this is the fully
    // qualified package name.  Examples: 343200656, com.rovio.angrybirds
    optional string app_id = 6;

    // The type of mobile device in which the ad will be shown.
    enum MobileDeviceType {
      UNKNOWN = 0;
      HIGHEND_PHONE = 1;
      TABLET = 2;
    }
    optional MobileDeviceType mobile_device_type = 8 [default = UNKNOWN];

    // The screen orientation of the device when the ad request is sent.
    enum ScreenOrientation {
      SCREEN_ORIENTATION_UNKNOWN = 0;
      SCREEN_ORIENTATION_PORTRAIT = 1;
      SCREEN_ORIENTATION_LANDSCAPE = 2;
    }
    optional int32 screen_orientation = 9 [default = 0];

    // If true, then this is a mobile full screen ad request.
    optional bool is_interstitial_request = 10 [default = false];

    // This field contains the IDs of categories to which the current mobile app
    // belongs.  This field will be empty if is_app is false.  The mapping
    // between mobile apps and categories is defined by the Google Play Store
    // for Android apps, or the Apple iTunes Store for iOS apps.  To look up
    // category name from category ID, please refer to
    // https://developers.google.com/adwords/api/docs/appendix/mobileappcategories
    repeated int32 app_category_ids = 11;
  }

  optional Mobile mobile = 28;

  // Information about the video if this is an in-video ad request.
  //
  message Video {
    // The time in milliseconds from the start of the video when the ad will be
    // displayed.  0 means pre-roll and -1 means post-roll.  The value is valid
    // only if this param is set.  When not set, the display position is
    // unknown.
    optional int32 videoad_start_delay = 1;

    // The maximum duration in milliseconds of the ad that you should return.
    // If this is not set or has value <= 0, any duration is allowed.
    optional int32 max_ad_duration = 2;

    // The minimum duration in milliseconds of the ad that you should return.
    // If this is not set or has value <= 0, there is no minimum duration.
    optional int32 min_ad_duration = 8;

    // The type of inventory from which request is sent.
    enum InventoryType {
      WEB_VIDEO = 0;
      GAMES = 1;
      MOBILE_INTERSTITIAL = 2;
    }

    optional int32 inventory_type = 3 [default = 0];

    // Does the publisher allow/require/block skippable video ads?  If this
    // field is not set, skippable ads are allowed.
    enum SkippableBidRequestType {
      ALLOW_SKIPPABLE = 0;
      REQUIRE_SKIPPABLE = 1;
      BLOCK_SKIPPABLE = 2;
    }
    optional SkippableBidRequestType video_ad_skippable = 4 [default =
        ALLOW_SKIPPABLE];

    // The maximum duration in milliseconds for the ad you should return, if
    // this ad is skippable (this generally differs from the maximum duration
    // allowed for non-skippable ads).  If this is not set or has value <= 0,
    // any duration is allowed.
    optional int32 skippable_max_ad_duration = 5;

    // The video technologies that are allowed for this request. The response
    // should support at least one of them.
    enum VideoFormat {
      VIDEO_FLASH = 0;
      VIDEO_HTML5 = 1;  // Valid HTML5 VAST ads contain both mp4 and webm media
                        // files in the first Ad/Creative VAST node.
    };
    repeated VideoFormat allowed_video_formats = 6;

    // Information about the companion ad slots that can be shown with the
    // video.  While this is a repeated field there will only be one value in
    // most cases.  If there are no companion ads available this field will not
    // be set.
    //
    message CompanionSlot {
      // These fields represent the available heights and widths in this slot.
      // There will always be the same number heights and widths fields.
      repeated int32 height = 1 [packed=true];
      repeated int32 width  = 2 [packed=true];

      // These are the formats of the creatives allowed in this companion ad slot.
      enum CreativeFormat {
        IMAGE_CREATIVE = 0;
        FLASH_CREATIVE = 1;
        HTML_CREATIVE  = 2;
      }
      repeated CreativeFormat creative_format = 3;
    }
    repeated CompanionSlot companion_slot = 7;
  }
  optional Video video = 29;

  // This is deprecated.  Please ignore.
  repeated string DEPRECATED_excluded_click_through_url = 18;

  // This is deprecated.  Please use the uint64 publisher_settings_list_id field
  // instead.
  optional bytes DEPRECATED_publisher_settings_list_id = 23;

  // The publisher settings list id that applies to this page.  See the
  // Targeting section of the RTB documentation for details.
  optional fixed64 publisher_settings_list_id = 42;

  // This is deprecated.  Please ignore.
  //
  message MatchingNetwork {
    // This is deprecated.  Please ignore.
    optional string DEPRECATED_network_id = 1;

    // This is deprecated.  Please ignore.
    optional string DEPRECATED_google_user_id = 2;
  }
  repeated MatchingNetwork DEPRECATED_matching_network = 27;
 
  // -----------------------------------------------------------
  // Information about the adslots on the page.
  //
  message AdSlot {

    // An arbitrarily assigned slot id that is unique on a given page and
    // usually starts counting from 1.  You use this to identify which slot to
    // bid on in the BidResponse.
    required int32 id = 1;

    // Unique identifier for this adslot's ad block for the page URL.
    optional uint64 ad_block_key = 14;

    // Set of channels of which this ad slot is a member.  A channel is a set of
    // ad slots on a site.  You can target a channel (like "the sports section",
    // or "all top banners") to get more fine-grained control over where your ad
    // shows.  Channel names are provided by the publisher.
    repeated string targetable_channel = 10;

    // The width and height in pixels of the allowed ad sizes.  Most requests
    // allow only a single size, but some allow more than one.  Widths and
    // heights must be at the same index.  For example, if the width values are
    // [728, 300, 468] and the height values are [90, 250, 60], then the allowed
    // formats are 728x90, 300x250, and 468x60.  Note that most requests that
    // allow more than one size are for video.  Those requests with more than
    // one size that are not video usually have excluded_attribute=21
    // (CreativeType:Html) which means that you cannot respond with a creative
    // that uses the html_snippet field in the BidResponse.
    repeated int32 width = 2;
    repeated int32 height = 3;

    // The disallowed attribute ids for the ads that can show in this slot. See
    // the creative-attributes.txt file in the technical documentation for a
    // list of ids.
    repeated int32 excluded_attribute = 4 [packed=true];

    // This is deprecated.  Please use excluded_attribute instead.
    repeated int32 DEPRECATED_allowed_attribute = 5;

    // The allowed vendor types.  See the vendors.txt file in the technical
    // documentation for a list of ids.  When the seller_network is GDN, the
    // vendor ids listed in gdn-vendors.txt in the supporting technical
    // documentation are also allowed.
    repeated int32 allowed_vendor_type = 6 [packed=true];

    // The disallowed sensitive ad categories.  See the
    // ad-sensitive-categories.txt file in the technical documentation for a
    // list of ids.  You should enforce these exclusions if you have the ability
    // to classify ads into the listed categories.
    repeated int32 excluded_sensitive_category = 7 [packed=true];

    // The disallowed ad product categories. See the ad-product-categories.txt
    // file in the technical documentation for a list of ids.  You should
    // enforce these exclusions if you have the ability to classify ads into the
    // listed categories.
    repeated int32 excluded_product_category = 13 [packed=true];

    // This is deprecated.  Please ignore.
    repeated string DEPRECATED_excluded_click_through_url = 8;

    // Information about the pre-targeting campaigns and adgroups that matched.
    //
    message MatchingAdData {
      // This is deprecated.  Please ignore.
      optional int64 DEPRECATED_campaign_id = 1;

      // The adgroup id of the matching ad.
      optional int64 adgroup_id = 2;

      // This is deprecated.  Please ignore.
      optional bool DEPRECATED_per_buyer_minimum_cpm = 3;

      // This is deprecated.  Please use fixed_cpm_micros within direct_deal
      // instead.
      optional int64 DEPRECATED_fixed_cpm_micros = 4;

      // The minimum CPM value that you can bid to not be filtered before the
      // auction.  This may be a global minimum, or it may be a minimum set by
      // the publisher.  The value is in micros of your account currency.
      optional int64 minimum_cpm_micros = 5;

      // Information about any direct deals you matched for this inventory.
      //
      message DirectDeal {
        // An id identifying the deal.
        optional int64 direct_deal_id = 1;

        // The fixed CPM deal that applies to your account for this adslot.  If
        // you choose to bid on this impression, then you must bid at least the
        // value of fixed_cpm_micros, and if you win, you will always be charged
        // fixed_cpm_micros.  The value is in micros of your account currency.
        // For example, if the fixed cpm is 1290000 (1.29 in your account
        // currency), then you need to bid at least this amount.  If you win,
        // you will be charged a CPM of 1.29 in your account currency.
        optional int64 fixed_cpm_micros = 2;
      }
      repeated DirectDeal direct_deal = 6;
    }
    repeated MatchingAdData matching_ad_data = 9;

    // This field is deprecated and should not be used.  Please use the uint64
    // publisher_settings_list_id field instead.
    repeated bytes DEPRECATED_publisher_settings_list_id = 11;

    // The publisher settings list ids that apply to this slot.  See the
    // Targeting section of the RTB documentation for details.
    optional fixed64 publisher_settings_list_id = 15;

    // Visibility information for the slot.
    enum SlotVisibility  {
      NO_DETECTION = 0;
      ABOVE_THE_FOLD = 1;
      BELOW_THE_FOLD = 2;
    }
    optional SlotVisibility slot_visibility = 12 [default = NO_DETECTION];
  }
  repeated AdSlot adslot = 14;

  // -----------------------------------------------------------
  // Testing flags.

  // If true, then this is a test request.  Results will not be displayed to
  // users and you will not be billed for a response even if it wins the
  // auction.  You should still do regular processing since the request may be
  // used to evaluate latencies or for other testing.
  optional bool is_test = 15 [default=false];

  // If true, then this request is intended to measure network latency.  Please
  // return an empty but parseable BidResponse (containing any required fields)
  // as quickly as possible without executing any bidding logic.
  optional bool is_ping = 17 [default=false];

  // If true, then this request is using an experimental deadline greater than
  // the normal 100ms.  We will sometimes send a small number of requests with
  // experimental_deadline=true to evaluate the effect of different deadlines on
  // spend.  Requests with experimental_deadline=true are for real impressions
  // and you should bid on them normally.  However, if you use internal timeouts
  // to abort processing when it is taking too long as a way of keeping your
  // error rate low, then you can disable these internal timeouts for requests
  // with experimental_deadline=true.  The effect on your error rate will be
  // limited since we will only set this on a small percentage of requests.
  // Paying attention to experimental_deadline is optional, but you may choose
  // to do so if you would benefit from higher deadlines and therefore wish to
  // help us accurately measure the effect of raising them.
  optional bool experimental_deadline = 35 [default=false];
}

// This is the message that you return in response to a BidRequest.  You may
// specify a list of ads.  For each ad, you should provide a list of ad slots on
// which the ad can run.  Ad slots are identifed by the ids included in the
// BidRequest.  Each ad can win at most one ad slot.  If you do not wish to bid,
// submit a response with no ads and with just processing_time_ms set.
//
message BidResponse {
  // This is deprecated.  Please do not set.
  optional int32 DEPRECATED_protocol_version = 1;

  // If your bid wins, specify a unique identifier for the creative to be
  // served. This became mandatory on April 1, 2012.
  // -- For a creative hosted on your servers, the unique identifier chosen by
  //    you goes in the buyer_creative_id field of the BidResponse. Each
  //    buyer_creative_id you return must always be associated with the same
  //    creative. The identifier string that you create is limited to 64 bytes.
  // -- For a creative hosted by Google, the unique identifier provided by
  //    Google goes in the creative_id field of the BidResponse.

  message Ad {
    // A buyer-specific identifier for the creative in this ad.  If set, this
    // field can be used to communicate approval statuses when issues are found.
    // Do not specify the same id for different creatives, or all creatives will
    // be disapproved if a problem with a single ad is found.  Do not specify
    // different ids for the same creative in different responses, or no
    // creatives will be served, since approval status is assigned on a per-id
    // basis.
    optional string buyer_creative_id = 10;

    // The HTML snippet that will display the ad when inserted in the web page.
    // Please use adslot.adgroup_id to indicate which adgroup this snippet is
    // attributed to.  The adgroup must be one of the adgroups for the slot sent
    // in the BidRequest.  Only one of the following should be set:
    // html_snippet, creative_id, video_url, snippet_template.  Only set this
    // field if the BidRequest is NOT for an in-video ad (BidRequest.video is
    // NOT present).
    optional string html_snippet = 1;

    // Id of a creative hosted by Google.  Please use adslot.adgroup_id to
    // indicate which adgroup this creative belongs to.  We will check that the
    // creative is part of the adgroup and the adgroup is one of the adgroups
    // for the slot sent in the BidRequest.  Only one of the following should be
    // set: html_snippet, creative_id, video_url, snippet_template.
    optional int64 creative_id = 8;

    // The URL to fetch a video ad.  The URL should return an XML response that
    // conforms to the VAST 2.0 standard.  Please use adslot.adgroup_id to
    // indicate which adgroup to attribute this ad to.  The adgroup must be one
    // of the adgroups for the slot sent in the BidRequest.  Only one of the
    // following should be set: html_snippet, creative_id, video_url,
    // snippet_template.  Only set this field if the BidRequest is for an
    // in-video ad (BidRequest.video is present).
    optional string video_url = 9;

    // An HTML snippet in the form of a template and multiple parameter values.
    // You should use a template and parameters if you render multiple creatives
    // in one slot.  The template should contain macro values of the form %%PX%%
    // where X is the position in the list of corresponding template_parameter
    // messages starting at 0.  Each template_parameter corresponds to one
    // creative in the slot.  For example, if the template is <iframe
    // src="http://a.tag.com/render?c=%%P0%%&c=%%P1%%"/> and the first
    // template_parameter.parameter_value is "123" and the second is "456", then
    // the final snippet after substitutions is <iframe
    // src="http://a.tag.com/render?c=123&c=456"/>.  The snippet must render
    // properly with all subsitutions, and it must also render properly with
    // only one parameter at a time substituted and the others replaced by their
    // blank_ad_parameter_value.  For the latter case, any creatives
    // corresponding to blank ad parameters must appear as blank rectangles at
    // the specified bounding boxes.  For the above example, assume the
    // blank_ad_parameter_value for the first parameter is "non".  The following
    // snippet has the second parameter substituted with the parameter_value,
    // and the first substituted with a blank_ad_parameter_value: <iframe
    // src="http://a.tag.com/render?c=none&c=456"/>.  This should render with
    // the bounding box of the first creative appearing as an empty rectangle
    // and the second creative appearing normally.  Only one of the following
    // should be set: html_snippet, creative_id, video_url, snippet_template.
    optional string snippet_template = 12;
    message TemplateParameter {
      // The value of the parameter to substitute into the template.
      optional string parameter_value = 1;

      // An alternate value of the parameter that when substituted into the
      // template will render a blank ad in the same bounding box as the real
      // ad.
      optional string blank_ad_parameter_value = 8;

      // A buyer-specific creative id.  See the description in the parent
      // message for more details.  The field in the parent message should not
      // be set when using a template.
      optional string buyer_creative_id = 2;

      // The destination URL for the creative.  See the description in the
      // parent message for more details.  The field in the parent message
      // should not be set when using a template.  Only a single URL is allowed,
      // unlike the field in the parent message.
      optional string click_through_url = 3;

      // The bounding box within the slot where the creative corresponding to
      // this parameter is rendered.  All the values are in pixels and (0,0)
      // coordinate is the bottom left corner.  For example, if the slot size is
      // 320x250 and the first creative occupies the top half of the slot, then
      // the bounding box values should be "left: 0 right: 320 top: 250 bottom
      // 125".
      optional int32 left = 4;
      optional int32 right = 5;
      optional int32 top = 6;
      optional int32 bottom = 7;

      // Set this value if the parameter represents a backup ad for a parameter
      // at another index.  For example, if this parameter represents a backup
      // for the parameter at index 2, then backup_index=2.  Backup ads are not
      // required.  They should only be used in cases where non-backup ads may
      // need replacement for reasons that can change in the few milliseconds
      // between the time you submit the bid and the time the ad is shown to
      // user.  For example, budget or frequency capping constraints may fit
      // this requirement.  All parameters representing backup ads should come
      // after the non-backup parameters in the repeated template_parameter
      // field.
      optional int32 backup_index = 9;
    };
    repeated TemplateParameter template_parameter = 13;

    // This is deprecated.  Please use the repeated click_through_url instead.
    optional string DEPRECATED_click_through_url = 2;

    // The set of destination URLs for the snippet.  This should include the
    // URLs that the user will go to if they click on the displayed ad, and any
    // URLs that are visible in the rendered ad.  It should not include
    // intermediate calls to the adserver that are unrelated to the final
    // landing page.  This data is used for post-filtering of publisher-blocked
    // URLs among other things.  A BidResponse that returns a snippet or video
    // ad but declares no click_through_url will be discarded.  Only set this
    // field if html_snippet or video_url are set.
    repeated string click_through_url = 4;

    // All vendor types for the ads that may be shown from this snippet. You
    // should only declare vendor ids listed in the vendors.txt file in the
    // technical documentation.  We will check to ensure that the vendors you
    // declare are in the allowed_vendor_type list sent in the BidRequest for
    // AdX publishers, or in gdn-vendors.txt for GDN publishers.  Only set this
    // field if html_snippet or video_url are set.
    repeated int32 vendor_type = 5;

    // All attributes for the ads that may be shown from this snippet.  See
    // creative-attributes.txt in the technical documentation for a list of ids.
    // We will check to ensure none of these attributes are in the
    // excluded_attribute list in the BidRequest.  Only set this field if
    // html_snippet or video_url are set.
    repeated int32 attribute = 6;

    // All sensitive categories for the ads that may be shown from this snippet.
    // See ad-sensitive-categories.txt in the technical documentation for a list
    // of ids.  We will check to ensure none of these categories were in the
    // excluded_sensitive_category list in the BidRequest.  Only set this field
    // if html_snippet or video_url are set.
    repeated int32 category = 7;

    // All names of the ad's advertisers.
    repeated string advertiser_name = 11;

    // The width and height in pixels of the ad.  Setting these is optional if
    // the BidRequest.AdSlot has only one width and height.  These must be set
    // if the bid BidRequest.AdSlot has more than one width and height.
    optional int32 width = 14;
    optional int32 height = 15;

    message AdSlot {
      // The slot id from the BidRequest that the ad may appear in.
      required int32 id = 1;

      // The maximum CPM you want to be charged if you win the auction for this
      // ad slot, expressed in micros of your account currency.  For example, to
      // bid a CPM of 1.29 USD, set max_cpm_micros = 1290000.  Winning bids are
      // rounded up to billable units.  For example, in USD, bids are rounded up
      // to the next multiple of 10,000 micros (one cent).
      required int64 max_cpm_micros = 2;

      // The minimum CPM you want to be charged if you win the auction for this
      // ad slot.  This may represent a second price if you choose max_cpm as
      // the highest of several bids, or some form of reserve price if you wish
      // to override the reserve price set by the publisher.  The bid must be
      // less than or equal to max_cpm_micros or it will be ignored.  This field
      // is optional and does not need to be set.
      optional int64 min_cpm_micros = 3;

      // Id of the adgroup to attribute this impression to.  The value must be
      // in the set of adgroups for this slot that were sent in the BidRequest.
      // This must always be set if the BidRequest has more than one
      // matching_ad_data.
      optional int64 adgroup_id = 4;
    }
    repeated AdSlot adslot = 3;
  }
  repeated Ad ad = 2;

  // If is_test was set in the BidRequest, then you may return debug information
  // as plain text in this field.  Please do not set this field under normal
  // conditions, or set it to values longer than 100 characters.  You should
  // only use this field when asked to do so as part of troubleshooting
  // particular problems.
  optional string debug_string = 5;

  // Please set this to the processing time in milliseconds from when you
  // received the request to when you returned the response.
  optional int32 processing_time_ms = 4;
}

Validation

It would be useful for testing if there was a way to check if a protobuf object was valid. A simple valid? method would suffice...

Passing nil for a required field (with a default) causes a client timeout

A request that looks something like this:

message SomeMessage {
  required string id                   = 1;
  required double balance                = 2 [ default = 0.0 ];
  required double interest_rate          = 3 [ default = 0.0 ];
  required SomeType type = 4;
}

and a request that looks something like this:

{:service=>Service, :method=>"deliver_data", :host=>"[FILTERED]", :port=>[FILTERED], :request=>datas {
  id: "f4492d61b37e"
  balance: #
  interest_rate: nil
  type: MEASURED
}
, :request_type=>Request, :response_type=>Response, :async=>false, :timeout=>30}

This causes a server hang and subsequently a timeout

last line in the protobuf log before it times out:

D, [2012-02-09T15:09:38.280547 #11350] DEBUG -- : [server] Post init, new read buffer created

Issues on Ubuntu

This gem works perfectly on my OSX based Mac -- but when I put things up on a Ubuntu 12.04 staging machine, I get a few different errors with the same code:

rep = Orchestration::Reply.new
rep.was_successful = false

On OSX the code executes perfectly. On Ubuntu, I get the following error message:

NameError: uninitialized constant Protobuf::Logger
        from /home/deployer/.gem/gems/protobuf-2.8.0/lib/protobuf/field/bytes_field.rb:40:in `rescue in block (2 levels) in define_setter'
        from /home/deployer/.gem/gems/protobuf-2.8.0/lib/protobuf/field/bytes_field.rb:29:in `block (2 levels) in define_setter'
        from (irb):50
        from /usr/local/bin/irb:12:in `<main>'

or

NoMethodError: undefined method `print_deprecation_warnings?' for Protobuf:Module
        from /home/deployer/.gem/gems/protobuf-2.8.8/lib/protobuf/field/base_field.rb:134:in `warn_if_deprecated'
        from /home/deployer/.gem/gems/protobuf-2.8.8/lib/protobuf/field/base_field.rb:206:in `block (2 levels) in define_setter'
        from (irb):60
        from /usr/local/bin/irb:12:in `<main>'

Both machines are running ruby 2.0.0p247 and libprotoc 2.4.1.

Both of the methods seem to be errors in the error reporting functionality, so this may be indicative of something else -- like a missing dependency, but I've installed the protobuf libraries.

Update: Ended up fixing this. The *.pb.rb files don't have the include for 'protobuf', which was included in one of the projects, but not the other.

Trying to parse file created by Python PB library

This is my first foray into PB, so be gently with me.

I have been running a MR task on Google App Engine writing out each record as PB record (using http://bit.ly/16NsDl1) into a file. I then moved this file to my Mac and was trying to use this library to read it back. Now the following produces an error:

irb(main):012:0> FeedHistory.parse f
ProtocolBuffers::DecodeError: incorrect wire type for tag: 4, expected 0 but got 2
#<ProtocolBuffers::Field::Uint64Field:0x007fa1bb94d338 @otype=:optional,   @name=:retrieved_epoch, @tag=4, @opts={}>

The .proto file looks like:

required uint64 feedhistory_id = 1;  
required uint64 user_id = 2;
optional uint64 served_epoch = 3;
optional uint64 retrieved_epoch = 4;

The head of the file looks like:

$ od -h output.pb | head
0000000      227b    7375    7265    695f    2264    203a    3834    3234
0000020      3133    3431    3538    3537    3231    3639    202c    7622
0000040      6469    6f65    2273    203a    7b5b    7622    6469    6f65
0000060      695f    2264    203a    6622    786f    6574    3a6c    3435
0000100      3732    3533    3838    2c22    2220    7561    6874    726f

Does anybody have any ideas on how I could further debug this?

Cheers.
-amx

Messages with massive tag numbers create huge memory footprint

There is a line in the Google UnitTest proto definition that defines a message with two fields, where one of the fields has a number > 268 million.

This causes the process to grow from ~80mb to over 2gb.

This is caused by the field storage mechanism in a message being an Array. A hash implementation has been used in the past to find fields in an array but array indexing is obviously much faster and since all fields have unique numbers it works out just dandy. The issue then is that with a gap of >280 million between the first and second tags on a message, we have a massive array full of nils which allocates a huge amount of space to store null references.

So, this isn't a problem we have to solve at all since a) the array solution currently works for the main default case and b) who in their right mind will use tag numbers so large. However, it could be an interesting problem to solve and so I wanted to open the issue to see if it went anywhere.

@devin-c and I discussed having a MAX_TAG_GAP size you could use to determine if/when a partitioning scheme could be used to prevent such massive arrays from being created.

Alternatively we could simply switch to a hash field storage solution if the max tag gap size is crossed.

Making concurrent requests hangs when # of requests > # of workers

I ran into an odd problem when testing some code that makes concurrent RPC requests. Concurrent requests worked just fine sometimes, but other times they would simply hang and never continue. With some digging, I was able to determine that as long as the number of concurrent requests is not greater than the number of worker threads on the server, everything works fine (e.g. 5 concurrent requests to 5 workers = ๐Ÿ‘). Once I attempt to make 6 concurrent requests, it hangs again.

When making 6 request to 5 workers, I can see the first 5 received and responded to by the server, but the sixth never even hits the server. If I add more workers to the server, requests work fine again until I make more concurrent requests than there are workers.

Segmentation Fault in Ruby v2.0.0 p353

Ruby version 2.0.0 p353
Protobuf 2.8.12

=> Booting WEBrick
=> Rails 3.2.16 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

/Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:174: [BUG] Segmentation fault
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   the more detail of.

-- Control frame information -----------------------------------------------
c:0006 p:0057 s:0024 e:000022 METHOD /Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:174
c:0005 p:0061 s:0017 e:000016 BLOCK  /Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:228 [FINISH]
c:0004 p:---- s:0013 e:000012 CFUNC  :loop
c:0003 p:0031 s:0010 e:000009 METHOD /Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:225
c:0002 p:0009 s:0004 e:000003 BLOCK  /Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:120 [FINISH]
c:0001 p:---- s:0002 e:000001 TOP    [FINISH]

/Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:120:in `block in start'
/Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:225:in `run'
/Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:225:in `loop'
/Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:228:in `block in run'
/Users/dennis/.rvm/gems/ruby-2.0.0-p353@firefly/gems/protobuf-2.8.12/lib/protobuf/rpc/service_directory.rb:174:in `process_beacon'

...

Compiling definitions with Ruby 2.0.0-p0 :confused:

Compiling protobuf definitions in Ruby 2.0.0-p0 results in a seg fault. Not sure if the issue is rprotoc, or what. Here's the output:

Cleaning compiled ruby files
rprotoc --ruby_out=lib --proto_path=./definitions definitions/atlas/*.proto definitions/atlas/**/*.proto definitions/atlas/**/**/*.proto
/Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/protobuf-2.7.2/bin/rprotoc:55: [BUG] Segmentation fault
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   the more detail of.

-- Control frame information -----------------------------------------------
c:0008 p:---- s:0033 e:000032 CFUNC  :_rprotoc_extern
c:0007 p:0114 s:0028 e:000027 METHOD /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/protobuf-2.7.2/bin/rprotoc:55
c:0006 p:0246 s:0022 e:000021 TOP    /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/protobuf-2.7.2/bin/rprotoc:62 [FINISH]
c:0005 p:---- s:0019 e:000018 CFUNC  :load
c:0004 p:0118 s:0015 E:001ad8 EVAL   /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/bin/rprotoc:23 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC  :eval
c:0002 p:0072 s:0005 E:0008a0 EVAL   /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/bin/ruby_noexec_wrapper:14 [FINISH]
c:0001 p:0000 s:0002 E:001088 TOP    [FINISH]

/Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/bin/ruby_noexec_wrapper:14:in `<main>'
/Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/bin/ruby_noexec_wrapper:14:in `eval'
/Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/bin/rprotoc:23:in `<main>'
/Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/bin/rprotoc:23:in `load'
/Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/protobuf-2.7.2/bin/rprotoc:62:in `<top (required)>'
/Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/protobuf-2.7.2/bin/rprotoc:55:in `compile_proto'
/Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/protobuf-2.7.2/bin/rprotoc:55:in `_rprotoc_extern'

-- C level backtrace information -------------------------------------------

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

* Loaded script: /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/bin/rprotoc

* Loaded features:

    0 enumerator.so
    1 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/enc/encdb.bundle
    2 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/enc/trans/transdb.bundle
    3 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/rbconfig.rb
    4 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/compatibility.rb
    5 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/defaults.rb
    6 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/deprecate.rb
    7 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/errors.rb
    8 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/version.rb
    9 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/requirement.rb
   10 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/platform.rb
   11 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb
   12 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/exceptions.rb
   13 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb
   14 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb
   15 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems.rb
   16 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/pathname.bundle
   17 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/pathname.rb
   18 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/user_interaction.rb
   19 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/etc.bundle
   20 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb
   21 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/rubygems_integration.rb
   22 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb
   23 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/shared_helpers.rb
   24 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/fileutils.rb
   25 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/gem_path_manipulation.rb
   26 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/gem_helpers.rb
   27 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/match_platform.rb
   28 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/rubygems_ext.rb
   29 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/version.rb
   30 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler.rb
   31 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/settings.rb
   32 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/path_support.rb
   33 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/digest.bundle
   34 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/digest.rb
   35 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/digest/sha1.bundle
   36 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/set.rb
   37 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/definition.rb
   38 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/dependency.rb
   39 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/ruby_dsl.rb
   40 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/dsl.rb
   41 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/source.rb
   42 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri/common.rb
   43 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri/generic.rb
   44 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri/ftp.rb
   45 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri/http.rb
   46 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri/https.rb
   47 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri/ldap.rb
   48 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri/ldaps.rb
   49 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri/mailto.rb
   50 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/uri.rb
   51 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/socket.bundle
   52 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/socket.rb
   53 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/fcntl.bundle
   54 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/timeout.rb
   55 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/thread.rb
   56 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/openssl.bundle
   57 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/openssl/bn.rb
   58 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/openssl/cipher.rb
   59 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/stringio.bundle
   60 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/openssl/config.rb
   61 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/openssl/digest.rb
   62 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/openssl/x509.rb
   63 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/openssl/buffering.rb
   64 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/openssl/ssl.rb
   65 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/openssl.rb
   66 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/securerandom.rb
   67 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/resolv.rb
   68 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/remote_fetcher.rb
   69 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/text.rb
   70 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/name_tuple.rb
   71 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb
   72 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/source/rubygems.rb
   73 /Users/adam/Code/atlas/lib/atlas/version.rb
   74 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/source/path.rb
   75 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/strscan.bundle
   76 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/source/git.rb
   77 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/lockfile_parser.rb
   78 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/lazy_specification.rb
   79 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tsort.rb
   80 /Users/adam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/forwardable.rb
   81 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/spec_set.rb
   82 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/environment.rb
   83 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/runtime.rb
   84 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/index.rb
   85 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/remote_specification.rb
   86 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/dep_proxy.rb
   87 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/resolver.rb
   88 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/ui.rb
   89 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/endpoint_specification.rb
   90 /Users/adam/.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.3/lib/bundler/setup.rb
   91 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi_c.bundle
   92 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/platform.rb
   93 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/types.rb
   94 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/library.rb
   95 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/errno.rb
   96 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/pointer.rb
   97 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/memorypointer.rb
   98 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/struct_layout_builder.rb
   99 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/struct.rb
  100 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/union.rb
  101 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/managedstruct.rb
  102 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/callback.rb
  103 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/io.rb
  104 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/autopointer.rb
  105 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/variadic.rb
  106 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/enum.rb
  107 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi/ffi.rb
  108 /Users/adam/.rvm/gems/ruby-2.0.0-p0@atlas/gems/ffi-1.4.0/lib/ffi.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Based on the stacktrace, my guess would be something in FFI, but frankly, I'm out of my element when it comes to C/C++.

Default values should be set at object initialization

For protos that are defined such that:

message Simple {
  required int32 offset = 1 [default = 0];
}

The appropriate Ruby code is being generated for them, but Protobuf::Message#initialize will not set the proper default values.

I can't test a fix locally because of this issue with FFI on FreeBSD but the following should work:

    def initialize(fields = {})
      @values = {}

      self.class.all_fields.each do |field|
        self[field.name] = field.default unless field.default.nil?
      end

      fields.to_hash.each_pair do |name, value|
        self[name] = value unless value.nil?
      end
    end

Possible string parsing issue on jruby

I wrote a little repo with a test case to demo this. Basically, when using the protobuf gem (which is compatible with jruby), the string serialization step that hbase-jruby does on the serialized protocol buffer message produces a string that does not get parsed correctly on the other side. With 2 integer fields in a row, one of the numbers ends up being way larger than it should. Maybe this is a byte boundary issue? The repo includes a test case of roundtrip conversion that passes.

https://github.com/MichaelXavier/hbase_jruby_protobuf_corruption

I've posted this issue already on hbase-jruby's github, as I suspect the issue lies there. I wanted to post this here on the off chance that the issue is on protobuf's side.

Tests failing

First I get the following error:

protobuf/spec/lib/protobuf/enum_value_spec.rb:6:in `block in <top (required)>': undefined method `its' for RSpec::ExampleGroups::ProtobufEnumValue:Class (NoMethodError)

This is fixed by requiring "rspec/its", but then I get the following error:

 /spec/lib/protobuf_spec.rb failed
 rake aborted!
 TypeError: no implicit conversion from nil to integer

Similar errors occur on both Ruby 1.9.3 and 2.0.0.

Can you describe the exact environment the tests should be passing in?

Refactor long-running tests

Several tests run longer than 1 second each (the longest runs ~9 sec!). We need to fix this.

$ bx rspec -p --seed 48228 spec
Compiling test protos (use NO_COMPILE_TEST_PROTOS=1 to skip)
 protoc --plugin=./bin/protoc-gen-ruby --ruby_out=/code/src/gems/protobuf/spec/support -I /code/src/gems/protobuf/spec/support /code/src/gems/protobuf/spec/support/**/*.proto
.........................*...............*.................................................................................................................................................................................................................................................................................Suppress tag warning output with PB_NO_TAG_WARNINGS=1.
....................................................

Pending:
  Protobuf::Message#get_ext_field_by_name Need to get a proto compiled with extensions first
    # No reason given
    # ./spec/lib/protobuf/message_spec.rb:330
  Protobuf::Message#get_field_by_tag when tag does not reference a field returns nil
    # need to implement a range-limiting array sub-class for field access
    # ./spec/lib/protobuf/message_spec.rb:345

Top 10 slowest examples (23.11 seconds, 98.8% of total time):
  Functional ZMQ Client runs under heavy load
    10.07 seconds ./spec/functional/zmq_server_spec.rb:49
  Functional ZMQ Client when the server takes too long to respond responds with a timeout error
    5.01 seconds ./spec/functional/zmq_server_spec.rb:99
  Protobuf::Rpc::Client when using fiber based calls throws a timeout when client timeout is exceeded
    2 seconds ./spec/lib/protobuf/rpc/client_spec.rb:47
  Functional ZMQ Client runs fine when required fields are set
    1.15 seconds ./spec/functional/zmq_server_spec.rb:32
  Protobuf::Rpc::Client when using fiber based calls without reactor_running? calls failure_cb & throws a timeout when client timeout is exceeded
    1.09 seconds ./spec/lib/protobuf/rpc/client_spec.rb:79
  Protobuf::Rpc::Client when using fiber based calls without reactor_running? throws a timeout when client timeout is exceeded
    1.02 seconds ./spec/lib/protobuf/rpc/client_spec.rb:68
  Protobuf::Rpc::Client when using fiber based calls waits for response
    1 seconds ./spec/lib/protobuf/rpc/client_spec.rb:10
  Functional ZMQ Client when the request type is wrong calls the on_failure callback
    0.701 seconds ./spec/functional/zmq_server_spec.rb:85
  Functional ZMQ Client when a message is malformed calls the on_failure callback
    0.61265 seconds ./spec/functional/zmq_server_spec.rb:71
  protoc-gen-ruby reads the serialized request bytes and outputs serialized response bytes
    0.4479 seconds

Finished in 23.93 seconds
367 examples, 0 failures, 2 pending

Randomized with seed 48228

BigDecimals in Ruby 2.0/1.9.3

I ran in to an interesting issue when converting Ruby Float objects to Protobuf::Field::DoubleField objects in Ruby 2.0:

TypeError:
       Unacceptable value 115.69 for field projected_spending of type Protobuf::Field::DoubleField

Here's the code in question:

def projected_spending
  return 0 if transaction_total <= 0

  velocity = transaction_total / ::Time.now.day
  estimate = velocity * ::Time.now.end_of_month.day
  estimate.round(2)
end

I was able to fix it by calling to_f on the return value for my projected_spending method.

The same behavior can be observed when converting Active Support BigDecimal objects, with calling to_f on them first resolving the issue as well.

With a workaround in place, I'm able to move forward. I'm not sure what changed around floats in Ruby 2.0, but this seems very odd.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.