bson_ext and mac os x lion

159 views
Skip to first unread message

Scott Windsor

unread,
Jul 24, 2011, 2:20:59 PM7/24/11
to mongodb-user
After upgrading to lion, I'm getting the following exception when
trying start my rails app:

/opt/local/lib/ruby/gems/1.8/gems/bson-1.3.1/lib/../lib/bson/bson_c.rb:
24:in `serialize': failed to free buffer (RuntimeError)
from /opt/local/lib/ruby/gems/1.8/gems/bson-1.3.1/lib/../lib/bson/
bson_c.rb:24:in `serialize'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
cursor.rb:425:in `construct_query_message'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
cursor.rb:405:in `send_initial_query'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
cursor.rb:371:in `refresh'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
cursor.rb:87:in `next_document'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
db.rb:497:in `command'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
connection.rb:704:in `check_is_master'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
connection.rb:504:in `connect'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
connection.rb:656:in `setup'
from /opt/local/lib/ruby/gems/1.8/gems/mongo-1.3.1/lib/../lib/mongo/
connection.rb:101:in `initialize'
from /Users/scott/workspace/teachstreet/web-app/config/initializers/
mongo_config.rb:1:in `new'
from /Users/scott/workspace/teachstreet/web-app/config/initializers/
mongo_config.rb:1
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/
active_support/dependencies.rb:171:in
`load_without_new_constant_marking'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/
active_support/dependencies.rb:171:in `load'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/
active_support/dependencies.rb:547:in `new_constants_in'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/
active_support/dependencies.rb:171:in `load'
from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.10/lib/
initializer.rb:622:in `load_application_initializers'
from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.10/lib/
initializer.rb:621:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.10/lib/
initializer.rb:621:in `load_application_initializers'
from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.10/lib/
initializer.rb:176:in `process'
from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.10/lib/
initializer.rb:113:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.10/lib/
initializer.rb:113:in `run'
from /Users/scott/workspace/teachstreet/web-app/config/environment.rb:
18
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/
active_support/dependencies.rb:182:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/
active_support/dependencies.rb:182:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/
active_support/dependencies.rb:547:in `new_constants_in'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/
active_support/dependencies.rb:182:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.10/lib/commands/
server.rb:84
from ./script/server:3:in `require'
from ./script/server:3


config/initializers/mongo_config.rb:
MongoMapper.connection =
Mongo::Connection.new(TeachStreet::Config.get('mongod:host'),
TeachStreet::Config.get('mongod:port'), :logger =>
RAILS_DEFAULT_LOGGER)
MongoMapper.database = "metrics_#{Rails.env}"

I'm using ruby installed via macports:
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10]

I'm using bson 1.3.1 and bson_ext 1.3.1 and mongo 1.3.1

This does not raise an exception if I take out the bson_ext in my
Gemfile.

- scott

Alvin Richards

unread,
Jul 25, 2011, 6:53:06 AM7/25/11
to mongodb-user
Looks like a potential difference with OS-X Lion.

Have opened the following to track

https://jira.mongodb.org/browse/RUBY-303

Not had any other reports (so far) of specific OS-X Lion issues.

-Alvin

Eric

unread,
Jul 29, 2011, 6:38:08 PM7/29/11
to mongodb-user
Same problem in Snow Leopard.

Environment
================
Also using 1.3.1 for mongo, bson and bson_ext

ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin10.4.0]
Ruby Enterprise Edition 20090610

OS X 10.6.8

Stack trace
================

RuntimeError: failed to free buffer
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/bson-1.3.1/
lib/../lib/bson/bson_c.rb:24:in `serialize'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/bson-1.3.1/
lib/../lib/bson/bson_c.rb:24:in `serialize'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/cursor.rb:425:in
`construct_query_message'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/cursor.rb:405:in `send_initial_query'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/cursor.rb:371:in `refresh'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/cursor.rb:87:in `next_document'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/db.rb:497:in `command'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/connection.rb:704:in `check_is_master'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/connection.rb:504:in `connect'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/connection.rb:656:in `setup'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo-1.3.1/lib/../lib/mongo/connection.rb:101:in `initialize'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo_mapper-0.8.6/lib/mongo_mapper/connection.rb:8:in `new'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo_mapper-0.8.6/lib/mongo_mapper/connection.rb:8:in `connection'
/Users/emickelson/.rvm/gems/ree-1.8.6-p20090610@master/gems/
mongo_mapper-0.8.6/lib/mongo_mapper/connection.rb:33:in `database'
/Users/emickelson/Sites/enlighten2.x/spec/spec_helper.rb:44:
/Users/emickelson/Sites/enlighten2.x/script/spec:11:
-e:1:in `load'
-e:1:
> > I'm using bson 1.3.1 andbson_ext1.3.1 and mongo 1.3.1

Kyle Banker

unread,
Aug 2, 2011, 5:37:43 PM8/2/11
to mongodb-user
For those who are seeing this issue:

Can you provide a simple test case that reproduces this?

Kyle

Eric

unread,
Aug 8, 2011, 11:53:17 AM8/8/11
to mongodb-user
Problem identified. At least in my case. We are using a gem called
"csspool". This gem has a dependency on another gem called "ffi". The
"ffi" gem is a c extension for loading libraries. It is this c
extension that conflicts with bson_ext. The exact conflict is the
buffer_free method in buffer.h and buffer.c. This method is also
declared and implemented in "ffi". So now it's a loading issue as to
which one wins.

I have temporarily resolved this issue by renaming the declaration,
implementation and usage of the buffer_free method in bson_ext to
"bson_buffer_free".

Eric M.

Kyle Banker

unread,
Aug 11, 2011, 10:24:53 AM8/11/11
to mongodb-user
Update:

I've committed a fix to the Ruby driver which prefixes all the methods
in buffer.h with 'bson_'. This
fix will go out in the 1.4.0 release of the Ruby driver, but you can
try the fix now by installing bson_ext
from master. Just clone the repo, then run this:

gem build bson_ext.gemspec
gem install bson_ext-1.3.1.gem

You can follow the associated JIRA case here:
https://jira.mongodb.org/browse/RUBY-302

Scott Windsor

unread,
Aug 11, 2011, 12:28:58 PM8/11/11
to mongod...@googlegroups.com
Awesome - I'm using ffi as well, and it fixed it for me.

Thanks so much, Kyle!

- scott

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Kyle Banker

unread,
Aug 11, 2011, 4:44:34 PM8/11/11
to mongodb-user
My pleasure. Many thanks to Eric to identifying the ffi connection.
Reply all
Reply to author
Forward
0 new messages