Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruby 2.1.0 crashes when using a client initialised with options #479

Closed
weemaels opened this issue Nov 21, 2014 · 7 comments
Closed

ruby 2.1.0 crashes when using a client initialised with options #479

weemaels opened this issue Nov 21, 2014 · 7 comments

Comments

@weemaels
Copy link

require 'redis'
Redis.new(host: 'localhost').ping

When redis is not running on localhost, the code above makes ruby 2.1.0 abort.

Using the initialiser without options, raises the expected exception:
Redis.new.ping

@weemaels
Copy link
Author

Redis.new(host: '127.0.0.1').ping
This also works fine.
DNS related...?

@badboy
Copy link
Contributor

badboy commented Nov 21, 2014

With what error does it abort?
It throws an Redis::CannotConnectError in both cases for me.
Is your localhost set up correctly?

[1] pry(main)> Redis.new.ping
Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)
from /home/badboy/.gem/ruby/2.1.0/gems/redis-3.0.7/lib/redis/client.rb:290:in `rescue in establish_connection'
[2] pry(main)> Redis.new(host: "localhost").ping
Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (ECONNREFUSED)
from /home/badboy/.gem/ruby/2.1.0/gems/redis-3.0.7/lib/redis/client.rb:290:in `rescue in establish_connection'
[~]% host localhost
localhost has address 127.0.0.1
localhost has IPv6 address ::1

@weemaels
Copy link
Author

This looks more like an issue with the combination:
'localhost'
Ruby 2.1.0
OS X Yosemite 10.10.1

Commenting localhost for ip6 in my hosts table, 'solved' the issue.

@badboy
Copy link
Contributor

badboy commented Nov 21, 2014

Not redis-rb's error then ;)

@weemaels
Copy link
Author

agreed!

/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:129: [BUG] rb_sys_fail_str(connect(2) for [fe80::1%lo0]:6379) - errno == 0
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.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
for more details.

-- Control frame information -----------------------------------------------
c:0025 p:---- s:0092 e:000091 CFUNC :connect_nonblock
c:0024 p:0062 s:0088 e:000087 BLOCK /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:129
c:0023 p:0071 s:0085 e:000084 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:121
c:0022 p:0015 s:0077 e:000076 BLOCK /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:162 [FINISH]
c:0021 p:---- s:0073 e:000072 IFUNC
c:0020 p:---- s:0071 e:000070 CFUNC :each
c:0019 p:---- s:0069 e:000068 CFUNC :each_with_index
c:0018 p:0045 s:0066 e:000065 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:160
c:0017 p:0072 s:0059 e:000058 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:211
c:0016 p:0018 s:0053 e:000052 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:304
c:0015 p:0007 s:0050 e:000049 BLOCK /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:85
c:0014 p:0026 s:0048 e:000047 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:266
c:0013 p:0023 s:0043 e:000042 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:84
c:0012 p:0078 s:0040 e:000039 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:326
c:0011 p:0007 s:0036 e:000035 BLOCK /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:197
c:0010 p:0020 s:0034 e:000033 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:279
c:0009 p:0009 s:0029 e:000028 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:196
c:0008 p:0011 s:0025 e:000024 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:102
c:0007 p:0010 s:0019 e:000018 BLOCK /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.rb:84
c:0006 p:0009 s:0016 e:000015 BLOCK /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.rb:37
c:0005 p:0014 s:0014 e:000013 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/monitor.rb:211
c:0004 p:0007 s:0011 e:000010 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.rb:37
c:0003 p:0007 s:0008 e:000007 METHOD /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.rb:83
c:0002 p:0033 s:0005 E:002230 EVAL test.rb:3 [FINISH]
c:0001 p:0000 s:0002 E:0002a8 TOP [FINISH]

test.rb:3:in <main>' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.rb:83:inping'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.rb:37:in synchronize' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/monitor.rb:211:inmon_synchronize'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.rb:37:in block in synchronize' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.rb:84:inblock in ping'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:102:in call' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:196:inprocess'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:279:in logging' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:197:inblock in process'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:326:in ensure_connected' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:84:inconnect'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:266:in with_reconnect' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:85:inblock in connect'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:304:in establish_connection' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:211:inconnect'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:160:in connect' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:160:ineach_with_index'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:160:in each' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:162:inblock in connect'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:121:in connect_addrinfo' /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:129:inrescue in connect_addrinfo'
/Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:129:in `connect_nonblock'

-- C level backtrace information -------------------------------------------
0 ruby 0x0000000101f176b0 rb_vm_bugreport + 144
1 ruby 0x0000000101dcc7e1 report_bug + 305
2 ruby 0x0000000101dcc6a4 rb_bug + 180
3 ruby 0x0000000101dcf665 rb_sys_fail_str + 197
4 socket.bundle 0x00000001021e660d rsock_sys_fail_raddrinfo + 61
5 socket.bundle 0x00000001021e65c5 rsock_sys_fail_sockaddr + 53
6 socket.bundle 0x00000001021e6661 rsock_sys_fail_raddrinfo_or_sockaddr + 81
7 socket.bundle 0x00000001021e6f2c sock_connect_nonblock + 204
8 ruby 0x0000000101f15d37 vm_call_cfunc + 1063
9 ruby 0x0000000101efd61d vm_exec_core + 11933
10 ruby 0x0000000101f0bd66 vm_exec + 134
11 ruby 0x0000000101f08978 rb_yield_values + 408
12 ruby 0x0000000101f101bd invoke_block_from_c + 541
13 ruby 0x0000000101f087b8 rb_yield + 184
14 ruby 0x0000000101d91199 rb_ary_each + 73
15 ruby 0x0000000101f12b71 vm_call0_body + 2305
16 ruby 0x0000000101f09258 iterate_method + 216
17 ruby 0x0000000101f08cb9 rb_iterate + 281
18 ruby 0x0000000101f0916d rb_block_call + 45
19 ruby 0x0000000101dc4bd9 enum_each_with_index + 73
20 ruby 0x0000000101f15d37 vm_call_cfunc + 1063
21 ruby 0x0000000101f15697 vm_call_method + 999
22 ruby 0x0000000101efd453 vm_exec_core + 11475
23 ruby 0x0000000101f0bd66 vm_exec + 134
24 ruby 0x0000000101f0cbfc rb_iseq_eval_main + 396
25 ruby 0x0000000101dd50b4 ruby_exec_internal + 148
26 ruby 0x0000000101dd4fde ruby_run_node + 78
27 ruby 0x0000000101d8e8df main + 79

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

  • Loaded script: test.rb

  • Loaded features:

    0 enumerator.so
    1 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/x86_64-darwin13.0/enc/encdb.bundle
    2 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/x86_64-darwin13.0/enc/trans/transdb.bundle
    3 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/x86_64-darwin13.0/rbconfig.rb
    4 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/compatibility.rb
    5 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/defaults.rb
    6 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/deprecate.rb
    7 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/errors.rb
    8 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/version.rb
    9 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/requirement.rb
    10 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/platform.rb
    11 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/basic_specification.rb
    12 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/stub_specification.rb
    13 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/util/stringio.rb
    14 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/specification.rb
    15 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/exceptions.rb
    16 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb
    17 thread.rb
    18 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/x86_64-darwin13.0/thread.bundle
    19 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/monitor.rb
    20 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb
    21 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems.rb
    22 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/path_support.rb
    23 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/dependency.rb
    24 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/errors.rb

    25 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/version.rb
    26 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/registry.rb
    27 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/command_helper.rb
    28 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/x86_64-darwin13.0/socket.bundle
    29 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/socket.rb
    30 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb
    31 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/connection.rb
    32 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/cgi/core.rb
    33 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/cgi/util.rb
    34 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/cgi/cookie.rb
    35 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/2.1.0/cgi.rb
    36 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb
    37 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/pipeline.rb
    38 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/subscribe.rb
    39 /Users/pascal/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis.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

[1] 20856 abort ruby test.rb

@cindyward1
Copy link

This is still a problem with localhost, Ruby 2.2.1 and OS X 10.9.5 (Mavericks). I had to restrict redis to ~>2.0 which meant I had to restrict resque to ~>1.23. I don't expect you to reopen the issue, I just want to document that whatever this problem is, it is not fixed in Ruby 2.2.1 and it affects OS X versions less than Yosemite.

@yaauie
Copy link
Collaborator

yaauie commented Mar 12, 2015

@cindyward1 There are other routes to your local host than the named alias localhost, which on your machine is resolving via IPv6 & causing the issue; 127.0.0.1 & 0.0.0.0 are generally acceptable IPv4 alternatives on a Mac (& other platforms too)

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

No branches or pull requests

4 participants