Skip to content

Instantly share code, notes, and snippets.

@ddonahue99
Created May 13, 2011 17:05
Show Gist options
  • Save ddonahue99/970901 to your computer and use it in GitHub Desktop.
Save ddonahue99/970901 to your computer and use it in GitHub Desktop.
NetHTTP seg fault in Ruby 1.9.2 with ActiveMerchant/Authorize.net
ruby-1.9.2-p180 :024 > response = gateway.purchase(1000, credit_card, options)
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
-- control frame ----------
c:0047 p:---- s:0218 b:0218 l:000217 d:000217 CFUNC :connect
c:0046 p:0011 s:0215 b:0215 l:000bd0 d:000214 BLOCK /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678
c:0045 p:0109 s:0213 b:0213 l:0001e0 d:0001e0 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:57
c:0044 p:0026 s:0201 b:0201 l:000200 d:000200 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:87
c:0043 p:0444 s:0195 b:0195 l:000bd0 d:000bd0 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678
c:0042 p:0011 s:0187 b:0187 l:000186 d:000186 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:637
c:0041 p:0048 s:0184 b:0184 l:000183 d:000183 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:626
c:0040 p:0025 s:0181 b:0181 l:000180 d:000180 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1168
c:0039 p:0041 s:0174 b:0174 l:000798 d:000798 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:978
c:0038 p:0191 s:0165 b:0165 l:001d20 d:000164 BLOCK /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/connection.rb:69
c:0037 p:0024 s:0163 b:0163 l:000162 d:000162 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:309
c:0036 p:0068 s:0157 b:0157 l:001d20 d:0015d0 BLOCK /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/connection.rb:62
c:0035 p:0020 s:0152 b:0152 l:000151 d:000151 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/connection.rb:139
c:0034 p:0015 s:0147 b:0147 l:001d20 d:001d20 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/connection.rb:56
c:0033 p:0242 s:0141 b:0141 l:000140 d:000140 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/posts_data.rb:48
c:0032 p:0020 s:0133 b:0132 l:000131 d:000131 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/posts_data.rb:30
c:0031 p:0023 s:0125 b:0125 l:000124 d:000124 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/posts_data.rb:26
c:0030 p:0111 s:0119 b:0119 l:000118 d:000118 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/billing/gateways/authorize_net.rb:
c:0029 p:0095 s:0108 b:0108 l:000107 d:000107 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/billing/gateways/authorize_net.rb:
c:0028 p:0019 s:0101 b:0101 l:0010f8 d:002220 EVAL (irb):24
c:0027 p:---- s:0098 b:0098 l:000097 d:000097 FINISH
c:0026 p:---- s:0096 b:0096 l:000095 d:000095 CFUNC :eval
c:0025 p:0028 s:0089 b:0089 l:000088 d:000088 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80
c:0024 p:0033 s:0082 b:0081 l:000080 d:000080 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/context.rb:254
c:0023 p:0031 s:0076 b:0076 l:001d38 d:000075 BLOCK /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:159
c:0022 p:0042 s:0068 b:0068 l:000067 d:000067 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:273
c:0021 p:0011 s:0063 b:0063 l:001d38 d:000062 BLOCK /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:156
c:0020 p:0144 s:0059 b:0059 l:000042 d:000058 BLOCK /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:243
c:0019 p:---- s:0056 b:0056 l:000055 d:000055 FINISH
c:0018 p:---- s:0054 b:0054 l:000053 d:000053 CFUNC :loop
c:0017 p:0009 s:0051 b:0051 l:000042 d:000050 BLOCK /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0016 p:---- s:0049 b:0049 l:000048 d:000048 FINISH
c:0015 p:---- s:0047 b:0047 l:000046 d:000046 CFUNC :catch
c:0014 p:0023 s:0043 b:0043 l:000042 d:000042 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:228
c:0013 p:0046 s:0040 b:0040 l:001d38 d:001d38 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:155
c:0012 p:0011 s:0037 b:0037 l:002168 d:000036 BLOCK /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:70
c:0011 p:---- s:0035 b:0035 l:000034 d:000034 FINISH
c:0010 p:---- s:0033 b:0033 l:000032 d:000032 CFUNC :catch
c:0009 p:0183 s:0029 b:0029 l:002168 d:002168 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:69
c:0008 p:0210 s:0024 b:0024 l:0009a0 d:0009a0 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/railties-3.0.7/lib/rails/commands/console.rb:44
c:0007 p:0019 s:0020 b:0020 l:000019 d:000019 METHOD /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/railties-3.0.7/lib/rails/commands/console.rb:8
c:0006 p:0430 s:0016 b:0016 l:000015 d:000015 TOP /Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/railties-3.0.7/lib/rails/commands.rb:23
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :require
c:0003 p:0061 s:0006 b:0006 l:0014e8 d:002428 EVAL script/rails:6
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0014e8 d:0014e8 TOP
---------------------------
-- Ruby level backtrace information ----------------------------------------
script/rails:6:in `<main>'
script/rails:6:in `require'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:69:in `start'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:69:in `catch'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:70:in `block in start'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:159:in `block (2 levels) in eval_input'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
(irb):24:in `irb_binding'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/billing/gateways/authorize_net.rb:112:in `purchase'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/billing/gateways/authorize_net.rb:246:in `commit'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/posts_data.rb:26:in `ssl_post'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/posts_data.rb:30:in `ssl_request'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/posts_data.rb:48:in `raw_ssl_request'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/connection.rb:56:in `request'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/connection.rb:139:in `retry_exceptions'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/connection.rb:62:in `block in request'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/ddonahue/.rvm/gems/ruby-1.9.2-p180@woo/gems/activemerchant-1.15.0/lib/active_merchant/common/connection.rb:69:in `block (2 levels) in request'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:978:in `post'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1168:in `request'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:626:in `start'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678:in `connect'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678:in `block in connect'
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678:in `connect'
-- C level backtrace information -------------------------------------------
[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
@ddonahue99
Copy link
Author

Turns out this was caused by building postgres against the macports version of openssl. Uninstalled openssl on macports, installed openssl and postgres via homebrew, and rebuilt the pg gem, now all is well.

@sadowski
Copy link

Had the same problem (net/http.rb:678) and ddonahue99's solution worked for me. Uninstall the macports version of openssl, install the brew version of openssl, brew uninstall postgress (because it was built with the wrong version of openssl), and brew install postgres again. Kind of odd that the error would show up in net_http, but this solution does work.

Also, to uninstall the port quickly use the 'follow-dependants' option:
sudo port uninstall --follow-dependents openssl

@paulgroves
Copy link

hat tip to @ddonahue99 - ditched MacPorts for Homebrew and like @sadowki all is good - thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment