EM.synchrony block causing segfault - ruby

Not entirely sure what's going on here, but I can't seem to call the EM.synchrony block without it crashing.
I'm using EM-Synchrony version 1.0.0 with EM-Http-Request version 1.0.0, and EventMachine version 1.0.0.beta.4. I'm attempting to run it on a Mac (Lion) using RVM and Ruby 1.9.2p290. Here's the backtrace from the segfault:
ruby-1.9.2-p290 :003 > EM.synchrony {}
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/em-synchrony-1.0.0/lib/em- synchrony.rb:25: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
-- control frame ----------
c:0035 p:---- s:0127 b:0127 l:000126 d:000126 CFUNC :resume
c:0034 p:0021 s:0124 b:0124 l:001fb8 d:002418 BLOCK /Users/ryan/.rvm/gems/ruby-1.9.2- p290#myapp/gems/em-synchrony-1.0.0/lib/em-synchrony.rb:25
c:0033 p:---- s:0122 b:0122 l:000121 d:000121 FINISH
c:0032 p:---- s:0120 b:0120 l:000119 d:000119 CFUNC :call
c:0031 p:---- s:0118 b:0118 l:000117 d:000117 CFUNC :run_machine
c:0030 p:0248 s:0115 b:0115 l:000114 d:000114 METHOD /Users/ryan/.rvm/gems/ruby-1.9.2- p290#myapp/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179
c:0029 p:0056 s:0108 b:0108 l:001fb8 d:001fb8 METHOD /Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/em-synchrony-1.0.0/lib/em-synchrony.rb:27
c:0028 p:0015 s:0101 b:0101 l:001d98 d:0007d8 EVAL (irb):3
c:0027 p:---- s:0099 b:0099 l:000098 d:000098 FINISH
c:0026 p:---- s:0097 b:0097 l:000096 d:000096 CFUNC :eval
c:0025 p:0028 s:0090 b:0090 l:000089 d:000089 METHOD /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/workspace.rb:80
c:0024 p:0033 s:0083 b:0082 l:000081 d:000081 METHOD /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/context.rb:254
c:0023 p:0031 s:0077 b:0077 l:0005d8 d:000076 BLOCK /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:159
c:0022 p:0042 s:0069 b:0069 l:000068 d:000068 METHOD /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:273
c:0021 p:0011 s:0064 b:0064 l:0005d8 d:000063 BLOCK /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:156
c:0020 p:0144 s:0060 b:0060 l:000043 d:000059 BLOCK /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/ruby-lex.rb:243
c:0019 p:---- s:0057 b:0057 l:000056 d:000056 FINISH
c:0018 p:---- s:0055 b:0055 l:000054 d:000054 CFUNC :loop
c:0017 p:0009 s:0052 b:0052 l:000043 d:000051 BLOCK /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0016 p:---- s:0050 b:0050 l:000049 d:000049 FINISH
c:0015 p:---- s:0048 b:0048 l:000047 d:000047 CFUNC :catch
c:0014 p:0023 s:0044 b:0044 l:000043 d:000043 METHOD /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/ruby-lex.rb:228
c:0013 p:0046 s:0041 b:0041 l:0005d8 d:0005d8 METHOD /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:155
c:0012 p:0011 s:0038 b:0038 l:0005b8 d:000037 BLOCK /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:70
c:0011 p:---- s:0036 b:0036 l:000035 d:000035 FINISH
c:0010 p:---- s:0034 b:0034 l:000033 d:000033 CFUNC :catch
c:0009 p:0183 s:0030 b:0030 l:0005b8 d:0005b8 METHOD /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:69
c:0008 p:0222 s:0025 b:0025 l:001d70 d:001d70 METHOD /Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/railties-3.1.1/lib/rails/commands/console.rb:45
c:0007 p:0019 s:0021 b:0021 l:000020 d:000020 METHOD /Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/railties-3.1.1/lib/rails/commands/console.rb:8
c:0006 p:0615 s:0017 b:0017 l:000016 d:000016 TOP /Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/railties-3.1.1/lib/rails/commands.rb:40
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:000b38 d:000308 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:000b38 d:000b38 TOP
---------------------------
-- Ruby level backtrace information ----------------------------------------
script/rails:6:in `<main>'
script/rails:6:in `require'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/railties-3.1.1/lib/rails/commands.rb:40:in `<top (required)>'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:69:in `start'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:69:in `catch'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:70:in `block in start'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:159:in `block (2 levels) in eval_input'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
(irb):3:in `irb_binding'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/em-synchrony-1.0.0/lib/em-synchrony.rb:27:in `synchrony'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `run'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `run_machine'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `call'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/em-synchrony-1.0.0/lib/em-synchrony.rb:25:in `block in synchrony'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290#myapp/gems/em-synchrony-1.0.0/lib/em-synchrony.rb:25:in `resume'
-- C level backtrace information -------------------------------------------
Any ideas?

Filed an issue on the EM-Synchrony GH repo. Igrigorik responded that it's a known bug with 1.9.2. Upgrading to 1.9.3 fixed this for me.

Related

Ruby (or FFI?) error when executing Jekyll commands

I want to create a new Webpage using Jekyll, but when I execute jekyll new <page>, Ruby crashes with a really long Crash Report that starts like this:
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275: [BUG] Bus Error at 0x0000000100e08000
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0027 p:---- s:0156 e:000155 CFUNC :attach
c:0026 p:0258 s:0150 e:000149 METHOD /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275
c:0025 p:0023 s:0130 e:000129 METHOD /Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:40
c:0024 p:0012 s:0125 e:000124 CLASS /Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native/native_context_api.rb:5
c:0023 p:0007 s:0122 e:000121 CLASS /Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native/native_context_api.rb:4
c:0022 p:0007 s:0119 e:000118 TOP /Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native/native_context_api.rb:3 [FINISH]
c:0021 p:---- s:0116 e:000115 CFUNC :require_relative
c:0020 p:0247 s:0111 e:000110 CLASS /Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:60
c:0019 p:0007 s:0107 e:000106 CLASS /Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:6
c:0018 p:0014 s:0104 e:000103 TOP /Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:5 [FINISH]
c:0017 p:---- s:0101 e:000100 CFUNC :require_relative
c:0016 p:0021 s:0096 e:000095 TOP /Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc.rb:31 [FINISH]
c:0015 p:---- s:0093 e:000092 CFUNC :require
c:0014 p:0110 s:0088 e:000087 METHOD /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54
c:0013 p:0006 s:0076 e:000075 TOP /Library/Ruby/Gems/2.6.0/gems/jekyll-sass-converter-2.2.0/lib/jekyll/converters/scss.rb:3 [FINISH]
c:0012 p:---- s:0073 e:000072 CFUNC :require
c:0011 p:0110 s:0068 e:000067 METHOD /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54
c:0010 p:0013 s:0056 e:000055 TOP /Library/Ruby/Gems/2.6.0/gems/jekyll-sass-converter-2.2.0/lib/jekyll-sass-converter.rb:4 [FINISH]
c:0009 p:---- s:0053 e:000052 CFUNC :require
c:0008 p:0110 s:0048 e:000047 METHOD /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54
c:0007 p:0226 s:0036 e:000035 TOP /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.2/lib/jekyll.rb:195 [FINISH]
c:0006 p:---- s:0033 e:000032 CFUNC :require
c:0005 p:0110 s:0028 e:000027 METHOD /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54
c:0004 p:0041 s:0016 e:000015 TOP /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.2/exe/jekyll:8 [FINISH]
c:0003 p:---- s:0013 e:000012 CFUNC :load
c:0002 p:0109 s:0008 E:001cc0 EVAL /usr/local/bin/jekyll:23 [FINISH]
c:0001 p:0000 s:0003 E:000cc0 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
/usr/local/bin/jekyll:23:in `<main>'
/usr/local/bin/jekyll:23:in `load'
/Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.2/exe/jekyll:8:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.2/lib/jekyll.rb:195:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/jekyll-sass-converter-2.2.0/lib/jekyll-sass-converter.rb:4:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/jekyll-sass-converter-2.2.0/lib/jekyll/converters/scss.rb:3:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `require_relative'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:5:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:6:in `<module:SassC>'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:60:in `<module:Native>'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:60:in `require_relative'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native/native_context_api.rb:3:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native/native_context_api.rb:4:in `<module:SassC>'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native/native_context_api.rb:5:in `<module:Native>'
/Library/Ruby/Gems/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:40:in `attach_function'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275:in `attach_function'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275:in `attach'
I am using a MacBook Pro with M1 Pro. Ruby has been installed via Homebrew and always worked fine on my Intel-MacBook. Does somebody know this error?
Regards,
Yannick
The issue was the following: I installed Ruby with Homebrew, but macOS ships its own Ruby, but in the wrong version. I followed this tutorial and that solved my problem.
I think it's an issue specific to M1 MacBooks, You can try
arch -arch x86_64 bundle install
arch -arch x86_64 bundle exec jekyll serve
Although I believe it's not an "ideal fix". Solution suggested by #Yannick seems promising, but I haven't tried it.

Stack level too deep with ruby

I am not doing anything fancy here; nothing. As a noob, could someone explain to me why this is happening? I am following this tutorial and I got the error:
Rails Console:
require 'bigdecimal' #=> false
sum = BigDecimal.new("0") #=> stack level too deep
So I thought, let me install BigDecimal and all would be ok. No. Same issue. Is this an issue with ruby 2.3.1p112? Does it has any affiliation with Rails 5 that Im using? Im in the console, not Rails. Thanks.
Stack Trace:
irb(main):001:0> BigDecimal.new("2.11")
SystemStackError: stack level too deep
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/xeroizer-2.16.4/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/xeroizer-2.16.4/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/xeroizer-2.16.4/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/xeroizer-2.16.4/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/xeroizer-2.16.4/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/xeroizer-2.16.4/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/xeroizer-2.16.4/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/xeroizer-2.16.4/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
... 10876 levels...
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `call'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/command_wrapper.rb:38:in `call'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:191:in `block in serve'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:161:in `fork'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:161:in `serve'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/sylar/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
irb(main):002:0>

Monkey patching Object leads to Pry deadlock

I'm trying to monkey patch Object and while my tests run fine,
I can't load my project with Pry anymore.
Here is the relevant code:
module CoreExtensions
def instance_values
instance_variables.each_with_object({}) do |var, hash|
hash[var[1..-1]] = instance_variable_get(var)
end
end
def ==(other)
(self.class == other.class) &&
(instance_values.equal? other.instance_values)
end
end
Object.include CoreExtensions
Using
pry -r ./core_extentions.rb
leads to this stacktrace:
Error: No live threads left. Deadlock?
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:87:in `sleep'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:87:in `wait'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:87:in `block in enter_interruptible_region'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:83:in `synchronize'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:83:in `enter_interruptible_region'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:110:in `interruptible_region'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:197:in `input_readline'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:190:in `block in read_line'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:129:in `handle_read_errors'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:170:in `read_line'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:98:in `read'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:68:in `block in repl'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:67:in `loop'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:67:in `repl'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:38:in `block in start'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:61:in `__with_ownership'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:79:in `with_ownership'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:38:in `start'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:15:in `start'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/pry_class.rb:169:in `start'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-byebug-3.3.0/lib/pry-byebug/pry_ext.rb:11:in `start_with_pry_byebug'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/cli.rb:219:in `block in <top (required)>'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/cli.rb:83:in `block in parse_options'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/cli.rb:83:in `each'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/cli.rb:83:in `parse_options'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/bin/pry:16:in `<top (required)>' /home/fap/.rvm/gems/ruby-2.3.0/bin/pry:23:in `load'
/home/fap/.rvm/gems/ruby-2.3.0/bin/pry:23:in main
/home/fap/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/home/fap/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in main
The same thing happens when I include my CoreExtentions in the main class.
I read about Pry's input_lock, but I don't understand what produces the deadlock.
Does anyone have an idea why this is happening?
You have redefined method == for all objects, which is not a good thing.
This comes about from the last line in your question, namely Object.include CoreExtentions
Without that definition, it loads fine.

How to use SASS to parse a list of all CSS selectors in an .scss file?

I'd like to programmatically parse an .scss file to generate a flat list of selectors that are used in that file, mostly as basis for some static code analysis.
In SASS terms, I'm looking for a way to get a list of all Sass::Tree::RuleNode for a given .scss file.
So far I'm using Sass::Engine.for_file to create a Tree. Then, in order to use Sass::Tree::RuleNode.resolved_rules on the individual Nodes I have to use Tree::Visitors::Cssize, according to the documentation. But somewhere in there is a (probably simple) error.
require 'sass'
sass_engine = Sass::Engine.for_file('files/examples.scss',{
:style => :compact,
:load_paths => ['files'],
:syntax => :scss,
})
tree = sass_engine.to_tree
Sass::Tree::Visitors::Cssize.visit(tree)
tree.each do |node|
if node.is_a? Sass::Tree::RuleNode
puts node.resolved_rules
end
end
This is the error and stacktrace I'm getting:
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:186:in `visit_prop': undefined method `empty?' for nil:NilClass (NoMethodError)
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:21:in `visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `map'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:30:in `block in visit_children'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:52:in `with_parent'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:29:in `visit_children'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:201:in `visit_rule'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:21:in `visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `map'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:30:in `block in visit_children'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:52:in `with_parent'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:29:in `visit_children'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:65:in `visit_root'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:21:in `visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:24:in `visit'
ruby-1.9.3-p362/gems/sass-3.2.10/lib/sass/tree/visitors/cssize.rb:6:in `visit'
Thanks a lot in advance.
I'm not overly familiar with the Sass gem codebase but was able to get this working (without crashing, at least) by following the code example of the Cssize class from sass gem's sass/tree/root_node.rb file, which has:
# Runs the dynamic Sass code *and* computes the CSS for the tree.
# #see #to_s
def render
Visitors::CheckNesting.visit(self)
result = Visitors::Perform.visit(self)
Visitors::CheckNesting.visit(result) # Check again to validate mixins
result, extends = Visitors::Cssize.visit(result)
Visitors::Extend.visit(result, extends)
result.to_s
end
Taking this code snippet and applying it to your script, I get:
#!/usr/bin/env ruby
require 'sass'
sass_engine = Sass::Engine.for_file('files/examples.scss',{
:style => :compact,
:load_paths => ['files'],
:syntax => :scss,
})
tree = sass_engine.to_tree
Sass::Tree::Visitors::CheckNesting.visit(tree)
result = Sass::Tree::Visitors::Perform.visit(tree)
Sass::Tree::Visitors::CheckNesting.visit(result)
result, extends = Sass::Tree::Visitors::Cssize.visit(result)
Sass::Tree::Visitors::Extend.visit(result, extends)
result.each do |node|
if node.is_a? Sass::Tree::RuleNode
puts node.resolved_rules
end
end

Why am I getting a segmentation fault in libxml_ruby.bundle when using the pivotal-tracker gem?

I have a Ruby 1.9.2-p290 program which is using the pivotal-tracker gem. The configuration of the application environment is using RVM. When I execute this on one machine the application works as expected yet on a different machine it results in the error below.
To simplify the problem I made a new ruby file with only the following contents and still receive the error:
require 'pivotal-tracker'
puts 'hello'
Given this works on one machine and not another I assume there is a configuration difference of some sort between the two.
What is the best way to debug what is going on to cause this error?
Thank you in advance!
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle:
> [BUG] Segmentation fault ruby 1.9.2p290 (2011-07-09 revision 32553)
> [x86_64-darwin10.8.0]
>
> -- control frame ---------- c:0027 p:-540275480 s:0094 b:0094 l:000093
> d:000093 TOP c:0026 p:---- s:0092 b:0092 l:000091 d:000091 CFUNC
> :require c:0025 p:0174 s:0088 b:0088 l:000087 d:000087 METHOD
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55
> c:0024 p:0074 s:0081 b:0081 l:000080 d:000080 TOP
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/libxml-ruby-1.1.4/lib/libxml.rb:9
> c:0023 p:---- s:0079 b:0079 l:000078 d:000078 FINISH c:0022 p:----
> s:0077 b:0077 l:000076 d:000076 CFUNC :require c:0021 p:0174 s:0073
> b:0073 l:000072 d:000072 METHOD
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55
> c:0020 p:0011 s:0066 b:0066 l:000065 d:000065 TOP
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/libxml-ruby-1.1.4/lib/xml.rb:11
> c:0019 p:---- s:0064 b:0064 l:000063 d:000063 FINISH c:0018 p:----
> s:0062 b:0062 l:000061 d:000061 CFUNC :require c:0017 p:0174 s:0058
> b:0058 l:000057 d:000057 METHOD
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55
> c:0016 p:0035 s:0051 b:0051 l:000050 d:000050 TOP
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/happymapper-0.3.2/lib/happymapper.rb:3
> c:0015 p:---- s:0049 b:0049 l:000048 d:000048 FINISH c:0014 p:----
> s:0047 b:0047 l:000046 d:000046 CFUNC :require c:0013 p:0174 s:0043
> b:0043 l:000042 d:000042 METHOD
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55
> c:0012 p:0035 s:0036 b:0036 l:000035 d:000035 TOP
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/pivotal-tracker-0.4.1/lib/pivotal-tracker.rb:3
> c:0011 p:---- s:0034 b:0034 l:000033 d:000033 FINISH c:0010 p:----
> s:0032 b:0032 l:000031 d:000031 CFUNC :require c:0009 p:0073 s:0028
> b:0028 l:000024 d:000027 BLOCK
> <internal:lib/rubygems/custom_require>:33 c:0008 p:0014 s:0025 b:0025
> l:000024 d:000024 METHOD <internal:lib/rubygems/custom_require>:29
> c:0007 p:0011 s:0020 b:0020 l:000019 d:000019 TOP
> /Users/isuttle/Projects/amazon_tracker/amzn_iteration.rb:1 c:0006
> p:---- s:0018 b:0018 l:000017 d:000017 FINISH c:0005 p:---- s:0016
> b:0016 l:000015 d:000015 CFUNC :require c:0004 p:0013 s:0012 b:0012
> l:000011 d:000011 METHOD <internal:lib/rubygems/custom_require>:29
> c:0003 p:0011 s:0007 b:0007 l:0014d8 d:001660 EVAL sample.rb:1
> c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000
> s:0002 b:0002 l:0014d8 d:0014d8 TOP
>
> Ruby level backtrace information sample.rb:1:in `<main>'
> <internal:lib/rubygems/custom_require>:29:in `require'
> <internal:lib/rubygems/custom_require>:29:in `require'
> /Users/isuttle/Projects/amazon_tracker/amzn_iteration.rb:1:in `<top
> (required)>' <internal:lib/rubygems/custom_require>:29:in `require'
> <internal:lib/rubygems/custom_require>:33:in `rescue in require'
> <internal:lib/rubygems/custom_require>:33:in `require'
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/pivotal-tracker-0.4.1/lib/pivotal-tracker.rb:3:in
> `<top (required)>'
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in
> `require'
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in
> `require'
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/happymapper-0.3.2/lib/happymapper.rb:3:in
> `<top (required)>'
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in
> `require'
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in
> `require'
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/libxml-ruby-1.1.4/lib/xml.rb:11:in
> `<top (required)>'
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in
> `require'
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in
> `require'
> /Users/isuttle/.rvm/gems/ruby-1.9.2-p290/gems/libxml-ruby-1.1.4/lib/libxml.rb:9:in
> `<top (required)>'
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in
> `require'
> /Users/isuttle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in
> `require'
It looks like libxml-ruby is the part that is segfaulting. I've had this before when system libraries have been updated possibly by:
System update (e.g. Snow Leopard to Lion)
Package updates (e.g. Homebrew, or Macports)
libxml-ruby is compiled against a specific version of the library libxml2, if the library is then updated it will sometimes work for a bit, but generally be unstable (like this). You could try and force it to recompile by doing something like:
$ gem uninstall libxml-ruby
$ gem install pivotal-tracker

Resources