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

Segfault on Ruby 2.5.0 and Rails 5.1.4 #652

Closed
chrismanderson opened this issue Jan 30, 2018 · 33 comments
Closed

Segfault on Ruby 2.5.0 and Rails 5.1.4 #652

chrismanderson opened this issue Jan 30, 2018 · 33 comments

Comments

@chrismanderson
Copy link

Howdy! Updating two Rails 5.1.4 apps to Ruby 2.5.0 and getting a simplecov segfault on both of them.

Occurs after the minitest suite finishes. The segfault sometimes references different simplecov files (even when just rerunning the suite, which is fun) I've attached two crash reports from the same project. Working on coming up with a sample project to upload as well. Happy to provide any additional information.

Rails 5.1.4
Ruby 2.5.0p0
Minitest 5.11.3
Simplecov 0.15.1

Tried rebundling, reinstalling 2.5.0. Only change made to the project was updating the Ruby version to 2.5.0, bundling, then running the tests; that was enough to cause the segfault.

Finished in 14.991489s, 17.2765 runs/s, 31.7513 assertions/s.
259 runs, 476 assertions, 0 failures, 0 errors, 0 skips
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52: [BUG] Segmentation fault at 0x0000700006fdb4b0
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

-- 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:0013 p:0023 s:0059 e:000057 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52
c:0012 p:0008 s:0053 e:000052 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0011 p:---- s:0049 e:000048 CFUNC  :reject
c:0010 p:0007 s:0045 e:000044 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0009 p:---- s:0041 e:000040 CFUNC  :each
c:0008 p:0015 s:0037 e:000036 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110
c:0007 p:0014 s:0031 e:000030 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83
c:0006 p:0042 s:0027 e:000026 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC  :new
c:0004 p:0049 s:0017 e:000016 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82
c:0003 p:0011 s:0013 e:000012 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180 [FINISH]
c:0002 p:0095 s:0010 e:000009 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68 [FINISH]
c:0001 p:0000 s:0003 E:000270 (none) [FINISH]
Finished in 14.715983s, 17.5999 runs/s, 32.3458 assertions/s.
259 runs, 476 assertions, 0 failures, 0 errors, 0 skips
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/source_file.rb:85: [BUG] Segmentation fault at 0x00007000064e54b0
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

-- 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:0014 p:0029 s:0064 e:000061 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/source_file.rb:85
c:0013 p:0005 s:0058 e:000057 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52
c:0012 p:0008 s:0053 e:000052 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0011 p:---- s:0049 e:000048 CFUNC  :reject
c:0010 p:0007 s:0045 e:000044 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0009 p:---- s:0041 e:000040 CFUNC  :each
c:0008 p:0015 s:0037 e:000036 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110
c:0007 p:0014 s:0031 e:000030 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83
c:0006 p:0042 s:0027 e:000026 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC  :new
c:0004 p:0049 s:0017 e:000016 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82
c:0003 p:0011 s:0013 e:000012 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180 [FINISH]
c:0002 p:0095 s:0010 e:000009 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68 [FINISH]
c:0001 p:0000 s:0003 E:001690 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68:in `block in <top (required)>'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180:in `block in at_exit'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82:in `result'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82:in `new'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31:in `initialize'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83:in `filter!'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110:in `filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110:in `each'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `block in filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `reject'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `block (2 levels) in filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52:in `matches?'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/source_file.rb:85:in `project_filename'
@PragTob
Copy link
Collaborator

PragTob commented Jan 30, 2018

Jeez... thanks. I'm inclined to say that it's in the coverage standard library (that we use) https://ruby-doc.org/stdlib-2.5.0/libdoc/coverage/rdoc/Coverage.html

If you replaced simplecov with require "coverage"; Coverage.start and somehow at the end of your tests p Coverage.result does it still happen?

@chrismanderson
Copy link
Author

I removed simplecov from my app, added in

require 'coverage'
require 'minitest/autorun'

Coverage.start
Minitest.after_run { p Coverage.result }

to my test_helper.rb and I did not get a segfault. Terminal was full of output from Coverage.result e.g. {"/Users/chris/store/admin/config/environment.rb"=>[nil, 1, nil, nil, 1], "/Users/chris/store/admin/config/application.rb"=>[1, nil, 1, nil, nil, nil, 1, nil, 1, 1, 1, nil, nil, nil, nil, nil...

but no segfault.

@chrismanderson
Copy link
Author

Ok weird discovery. With simplecov, I get the segfault when I run bin/rails test, but I do not get it if I run bundle exec rake. So seems like something in the rails binstub is potentially either causing the segfault or creating the conditions for the segfault to occur.

@PragTob
Copy link
Collaborator

PragTob commented Jan 30, 2018

Strange... thanks a lot for trying that out.

Could you please provide the crash report mentioned in the console output? I have no idea how this is happening we don't do anything too fancy so fear it's more or less trial and error to get it right/figure out what's the problem.

I'm not sure but line 68 is this one

config_path = Pathname.new(SimpleCov.root)

So maybe try running that code at some point before and it's just the Simplecov.root that fails us?

@PragTob
Copy link
Collaborator

PragTob commented Jan 30, 2018

@chrismanderson interesting... might also be something to do with spring then if you're using it. Oh I love spring ;P It might also be that some of our root or command detection code goes rogue, produces weird output that then down the line leads to the segfault.

I'm not big on minitest, but isn't there another way to run minitest test - like just executing them with ruby? Does it happen then?

@chrismanderson
Copy link
Author

I do not use spring cause I enjoy my sanity :) so that shouldn't be the issue. I've attached the crash report.

With my test_helper.rb set up as


require 'simplecov'
SimpleCov.start 'rails' do
  add_filter '.bundle'
end

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)

require 'rails/test_help'
require 'mocha/mini_test'
require 'sidekiq/testing'

Dir[Rails.root.join("test/support/**/*.rb")].each { |f| require f }

Sidekiq::Testing.fake!

If I try to execute one test manually, using ruby -Itest test/models/address_test.rb I get a load error /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in require': cannot load such file -- simplecov (LoadError)`.

Pretty sure has happened for a while, one of the reasons I always use the rails running to run the suite and single tests. Running bin/rails test test/models/address_test.rb runs just that file, and still causes the segfault.

-- Control frame information -----------------------------------------------
c:0013 p:0023 s:0059 e:000057 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52
c:0012 p:0008 s:0053 e:000052 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0011 p:---- s:0049 e:000048 CFUNC  :reject
c:0010 p:0007 s:0045 e:000044 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0009 p:---- s:0041 e:000040 CFUNC  :each
c:0008 p:0015 s:0037 e:000036 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110
c:0007 p:0014 s:0031 e:000030 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83
c:0006 p:0042 s:0027 e:000026 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC  :new
c:0004 p:0049 s:0017 e:000016 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82
c:0003 p:0011 s:0013 e:000012 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180 [FINISH]
c:0002 p:0095 s:0010 e:000009 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68 [FINISH]
c:0001 p:0000 s:0003 E:000360 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68:in `block in <top (required)>'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180:in `block in at_exit'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82:in `result'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82:in `new'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31:in `initialize'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83:in `filter!'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110:in `filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110:in `each'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `block in filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `reject'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `block (2 levels) in filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52:in `matches?'

I've attached a crash report from the full suite run. Trying to go through the simplecov running to see if I can find more of where the failure happens.
ruby_2018-01-30-165549_Blackbriar.txt

@chrismanderson
Copy link
Author

chrismanderson commented Jan 30, 2018

Ok so maybe it is the Coverage library. Maybe? 🤷‍♂️

If configure

SimpleCov.at_exit do
  p "Testing finished"
end

I do not get a segfault (Simplecov doesn't really do anything, but still, no segfault).

If I replace that with

SimpleCov.at_exit do
  puts Coverage.result.inspect
end

I do get a segfault. I would expect some long hash output, but not an exception. Not sure if I'm going down a rabbit hole in the wrong direction, but it is something at least. (And, if I do the same thing, puts Coverage in the at_exit block on Ruby 2.4.3, no segfault.)

@PragTob
Copy link
Collaborator

PragTob commented Jan 31, 2018

@chrismanderson try running not just ruby ... but bundle exec ruby ... - you should find simplecov then. Also interesting.

at least the coverage library c implementation appears in the backtrace of the crash log so maybeeeee 🤷‍♂️

I think it'd be worthwhile opening a bug at ruby-lang. Generally speaking, we don't have a C-extensions or something so segfaults occuring are most likely ruby interpreter (and mostly coverage library) bugs as ruby code shouldn't be able to segfault the RubyVM. 2.5 has also seen some work on the coverage library so might be an error slipped through...

@chrismanderson
Copy link
Author

Never knew you could preface ruby with bundle exec. Nice!

Running bundle exec ruby -Itest test/models/address_test.rb still segfaults. Offending line in this case is the same as before, seems to be

    # The path to this source file relative to the projects directory
    def project_filename
      @filename.sub(/^#{SimpleCov.root}/, "")
    end

I'll open an issue at ruby-lang. I didn't see any existing issues there; which is always disconcerting; but maybe there's some combination of the filelist/filename/content/etc that is causing the segfault.

@chrismanderson
Copy link
Author

chrismanderson commented Jan 31, 2018

Seems like someone else did open an issue that I missed when searching. No activity yet, but fingers crossed.

https://bugs.ruby-lang.org/issues/14334

@PragTob
Copy link
Collaborator

PragTob commented Jan 31, 2018

@chrismanderson could you please show me the values of @filename and Simplecov.root before that line?

like:

    def project_filename
      p @filename
      p SimpleCov.root
      @filename.sub(/^#{SimpleCov.root}/, "")
    end

and then show me the output? Thanks!

@chrismanderson
Copy link
Author

It gets through most, if not all the files in my project. Sadly, ends on different ones each time if I run different test files or the whole suite (though the list is consistent when rerunning the same command).

Whole suite

....
"/Users/chris/galley/my-app/.bundle/gems/tilt-2.0.8/lib/tilt/wikicloth.rb"
"/Users/chris/galley/my-app"
"/Users/chris/galley/my-app/.bundle/gems/timers-4.1.2/lib/timers.rb"
"/Users/chris/galley/my-app"
/Users/chris/galley/my-app/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/source_file.rb:87: [BUG] Segmentation fault at 0x0000700005a8c4b0
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

One model test

.....
"/Users/chris/galley/my-app"
"/Users/chris/galley/my-app/.bundle/gems/newrelic_rpm-4.7.1.340/lib/new_relic/agent/transaction_sampler.rb"
"/Users/chris/galley/my-app"
"/Users/chris/galley/my-app/.bundle/gems/newrelic_rpm-4.7.1.340/lib/new_relic/agent/transaction_state.rb"
"/Users/chris/galley/my-app"

Different model

....
"/Users/chris/galley/my-app"
"/Users/chris/galley/my-app/app/controllers/reporting/posts_controller.rb"
"/Users/chris/galley/my-app"
"/Users/chris/galley/my-app/app/controllers/reporting/posts_controller.rb"
"/Users/chris/galley/my-app"

Going to try later and get a sample project to recreate the issue. It's somewhat suspect that my two larger apps hit it, but a new sample project does not, so going to proceed down that path later today.

@PragTob
Copy link
Collaborator

PragTob commented Jan 31, 2018

Thanks for all the investigation. That all looks... oddly normal. The only odd thing that I spot is that you vendored your gems in .bundle and that coverage also runs for them. You could add a filter to ignore your .bundle directory... that might stop the bug from happening, still shouldn't happen but that's an idea.

@chrismanderson
Copy link
Author

I actually do have a filter turned on.

require 'simplecov'
SimpleCov.start 'rails' do
  add_filter ".bundle"
end

One thing I just noticed is where the exception is happening. When I do

    def project_filename
      p @filename
      p SimpleCov.root

      @filename.sub(/^#{SimpleCov.root}/, "")
    end

as mentioned above, the actual exception is happening on either of the p lines (in this case p SimpleCov.root). Which is really really weird I feel like.

/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/source_file.rb:87: [BUG] Segmentation fault at 0x000070000e1784b0
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

-- 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:0015 p:---- s:0067 e:000066 CFUNC  :p
c:0014 p:0014 s:0062 e:000061 METHOD /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/source_file.rb:87
c:0013 p:0005 s:0058 e:000057 METHOD /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/filter.rb:54
c:0012 p:0008 s:0053 e:000052 BLOCK  /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:116 [FINISH]
c:0011 p:---- s:0049 e:000048 CFUNC  :reject
c:0010 p:0007 s:0045 e:000044 BLOCK  /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:116 [FINISH]
c:0009 p:---- s:0041 e:000040 CFUNC  :each
c:0008 p:0015 s:0037 e:000036 METHOD /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:115
c:0007 p:0014 s:0031 e:000030 METHOD /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/result.rb:85
c:0006 p:0042 s:0027 e:000026 METHOD /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/result.rb:33 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC  :new
c:0004 p:0049 s:0017 e:000016 METHOD /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:87
c:0003 p:0011 s:0013 e:000012 BLOCK  /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/configuration.rb:182 [FINISH]
c:0002 p:0067 s:0010 e:000009 BLOCK  /Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/defaults.rb:30 [FINISH]
c:0001 p:0000 s:0003 E:000bc0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/defaults.rb:30:in `block in <top (required)>'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/configuration.rb:182:in `block in at_exit'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:87:in `result'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:87:in `new'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/result.rb:33:in `initialize'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/result.rb:85:in `filter!'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:115:in `filtered'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:115:in `each'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:116:in `block in filtered'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:116:in `reject'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov.rb:116:in `block (2 levels) in filtered'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/filter.rb:54:in `matches?'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/source_file.rb:87:in `project_filename'
/Users/chris/galley/admin/.bundle/bundler/gems/simplecov-f90a785f888b/lib/simplecov/source_file.rb:87:in `p'

@bf4
Copy link
Collaborator

bf4 commented Jan 31, 2018

Curious, trying setting SimpleCov.formatters = []

@chrismanderson
Copy link
Author

chrismanderson commented Feb 1, 2018

Same exception when I do

require 'simplecov'
SimpleCov.formatters = []
SimpleCov.start 'rails' do
  add_filter '.bundle'
end
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
....

at the top of my test_helper.rb

@bf4
Copy link
Collaborator

bf4 commented Feb 1, 2018

How about, based on the stack trace

require 'simpelcov'
def SimpleCov.at_exit
  proc do
    puts "I am a faked out at exist proc"
  end
end
# and for fun
at_exit { puts "I'm being called before SimpleCov's at_exit" }

@chrismanderson
Copy link
Author

chrismanderson commented Feb 1, 2018

That did not crash, outputted the text, though simplecov did not run.

require 'simplecov'
SimpleCov.start 'rails' do
  add_filter '.bundle'
end

def SimpleCov.at_exit
  proc do
    puts "I am a faked out at exist proc"
  end
end

ENV['RAILS_ENV'] ||= 'test'
# ... rest of test_helper ...

Same result basically as when I overrode at_exit directly as mentioned above.

SimpleCov.at_exit do
  p "Testing finished"
end

@bf4
Copy link
Collaborator

bf4 commented Feb 1, 2018

Well, that means it is for sure simplecov.

How about in the trace I missed it actually ends with https://github.com/colszowka/simplecov/blob/f90a785f888b/lib/simplecov/source_file.rb#L85-L88

class SimpleCov::SourceFile
    # The path to this source file relative to the projects directory
    def project_filename
      @filename.sub(/^#{SimpleCov.root}/, "")
    end
end

so

SimpleCov::SourceFile.class_eval do
  def project_filename
    p [:debug, @filename]
    p [:debug,   SimpleCov.root]
    File.basename(Dir.pwd)
  end
end

@chrismanderson
Copy link
Author

chrismanderson commented Feb 1, 2018

Basically the same result as putting puts into the gem itself above. Get the segfault during the puts itself (which obviously, is weird). (Line 8 translates to p [:debug, @filename] in your snippet above, and the segfault happens after outputting a long list of file names, not immediately.

[:debug, "/Users/chris/galley/my-app/.bundle/gems/activesupport-5.1.4/lib/active_support/core_ext/object/to_query.rb"]
[:debug, "/Users/chris/galley/my-app"]
/Users/chris/galley/my-app/test/test_helper.rb:8: [BUG] Segmentation fault at 0x000070000afdd4b0
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

-- 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:0017 p:---- s:0073 e:000072 CFUNC  :inspect
c:0016 p:---- s:0070 e:000069 CFUNC  :inspect
c:0015 p:---- s:0067 e:000066 CFUNC  :p
c:0014 p:0011 s:0062 e:000061 METHOD /Users/chris/galley/my-app/test/test_helper.rb:8
c:0013 p:0005 s:0058 e:000057 METHOD /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52
c:0012 p:0008 s:0053 e:000052 BLOCK  /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0011 p:---- s:0049 e:000048 CFUNC  :reject
c:0010 p:0007 s:0045 e:000044 BLOCK  /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0009 p:---- s:0041 e:000040 CFUNC  :each
c:0008 p:0015 s:0037 e:000036 METHOD /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110
c:0007 p:0014 s:0031 e:000030 METHOD /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83
c:0006 p:0042 s:0027 e:000026 METHOD /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC  :new
c:0004 p:0049 s:0017 e:000016 METHOD /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82
c:0003 p:0011 s:0013 e:000012 BLOCK  /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180 [FINISH]
c:0002 p:0095 s:0010 e:000009 BLOCK  /Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68 [FINISH]
c:0001 p:0000 s:0003 E:0020e0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68:in `block in <top (required)>'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180:in `block in at_exit'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82:in `result'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82:in `new'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31:in `initialize'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83:in `filter!'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110:in `filtered'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110:in `each'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `block in filtered'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `reject'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `block (2 levels) in filtered'
/Users/chris/galley/my-app/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52:in `matches?'
/Users/chris/galley/my-app/test/test_helper.rb:8:in `project_filename'
/Users/chris/galley/my-app/test/test_helper.rb:8:in `p'
/Users/chris/galley/my-app/test/test_helper.rb:8:in `inspect'
/Users/chris/galley/my-app/test/test_helper.rb:8:in `inspect'

-- Machine register context ------------------------------------------------
 rax: 0x00007ffab8f00780 rbx: 0x00000001099b7000 rcx: 0x0000000000000000
 rdx: 0x0000000000000005 rdi: 0x00007ffac015ecb8 rsi: 0x00007ffac0205790
 rbp: 0x00007ffee7c8d3e0 rsp: 0x00007ffee7c8d3b0  r8: 0x00007ffabfa30018
  r9: 0xcccccccccccccccd r10: 0x0000000000000000 r11: 0x0000000000000000
 r12: 0x000070000afdd4b0 r13: 0x3ffffffffffffff8 r14: 0x00007ffab8f00d80
 r15: 0x0000000000000143 rip: 0x0000000107ffa373 rfl: 0x0000000000010202

-- C level backtrace information -------------------------------------------
0   ruby                                0x000000010815bda7 rb_vm_bugreport + 135
1   ruby                                0x0000000107fe0e08 rb_bug_context + 472
2   ruby                                0x00000001080d0361 sigsegv + 81
3   libsystem_platform.dylib            0x00007fff7883df5a _sigtramp + 26
4   ruby                                0x0000000107ffa373 rb_gc_mark_machine_stack + 99
5   ruby                                0x000000010814ae09 rb_execution_context_mark + 137
6   ruby                                0x0000000107fc8b0b cont_mark + 27
7   ruby                                0x0000000108003a22 gc_start + 2434
8   ruby                                0x0000000108002f1f newobj_slowpath + 1055
9   ruby                                0x0000000108002ad4 newobj_slowpath_wb_protected + 20
10  ruby                                0x00000001080ed99e rb_str_inspect + 94
11  ruby                                0x0000000108156340 vm_call0_body + 560
12  ruby                                0x00000001081570c8 rb_call0 + 152
13  ruby                                0x00000001081423a1 rb_funcallv + 49
14  ruby                                0x000000010804dfa5 rb_inspect + 21
15  ruby                                0x0000000107f80666 inspect_ary + 246
16  ruby                                0x000000010810c22b exec_recursive + 891
17  ruby                                0x0000000108156340 vm_call0_body + 560
18  ruby                                0x00000001081570c8 rb_call0 + 152
19  ruby                                0x00000001081423a1 rb_funcallv + 49
20  ruby                                0x000000010804dfa5 rb_inspect + 21
21  ruby                                0x00000001080143fc rb_p + 28
22  ruby                                0x0000000108024759 rb_f_p_internal + 41
23  ruby                                0x0000000107feb4a1 rb_ensure + 193
24  ruby                                0x00000001080179df rb_f_p + 31
25  ruby                                0x000000010814f28e vm_call_cfunc + 286
26  ruby                                0x00000001081389c4 vm_exec_core + 12260
27  ruby                                0x0000000108149b5e vm_exec + 142
28  ruby                                0x0000000108157284 invoke_block_from_c_bh + 372
29  ruby                                0x0000000108144e7e rb_yield + 158
30  ruby                                0x0000000107f78b9a rb_ary_reject + 202
31  ruby                                0x000000010814f28e vm_call_cfunc + 286
32  ruby                                0x0000000108137f34 vm_exec_core + 9556
33  ruby                                0x0000000108149b5e vm_exec + 142
34  ruby                                0x0000000108157284 invoke_block_from_c_bh + 372
35  ruby                                0x0000000108144e7e rb_yield + 158
36  ruby                                0x0000000107f72b49 rb_ary_each + 41
37  ruby                                0x000000010814f28e vm_call_cfunc + 286
38  ruby                                0x0000000108137f34 vm_exec_core + 9556
39  ruby                                0x0000000108149b5e vm_exec + 142
40  ruby                                0x00000001081570c8 rb_call0 + 152
41  ruby                                0x00000001081423a1 rb_funcallv + 49
42  ruby                                0x000000010804e9d9 rb_class_s_new + 41
43  ruby                                0x000000010814f28e vm_call_cfunc + 286
44  ruby                                0x00000001081389c4 vm_exec_core + 12260
45  ruby                                0x0000000108149b5e vm_exec + 142
46  ruby                                0x000000010814863e vm_invoke_proc + 238
47  ruby                                0x00000001081506cf vm_call_opt_call + 159
48  ruby                                0x00000001081389c4 vm_exec_core + 12260
49  ruby                                0x0000000108149b5e vm_exec + 142
50  ruby                                0x000000010814863e vm_invoke_proc + 238
51  ruby                                0x000000010807ddc1 rb_proc_call + 81
52  ruby                                0x0000000107fe9df7 rb_exec_end_proc + 423
53  ruby                                0x0000000107fea3c2 ruby_finalize_0 + 130
54  ruby                                0x0000000107fea50f ruby_cleanup + 303
55  ruby                                0x0000000107fea7df ruby_run_node + 63
56  ruby                                0x0000000107f7001f main + 79

@bf4
Copy link
Collaborator

bf4 commented Feb 1, 2018

Is the last one a directory? "/Users/chris/galley/my-app"

Also, I thought "/Users/chris/galley/my-app/.bundle/gems/activesupport-5.1.4/lib/active_support/core_ext/object/to_query.rb" should have been excluded by the filter?

My .simplecov has

  # Exclude these paths from analysis
  add_filter '/config/'
  add_filter '/db/'
  add_filter 'tasks'
  add_filter '/.bundle/'

@bf4
Copy link
Collaborator

bf4 commented Feb 1, 2018

Also, File.basename(Dir.pwd) is pretty wrong code-wise. I put that there thinking it might be benign. I forget, can you rescue SystemExit on a segfault?

Looks like it may be GC?

4   ruby                                0x0000000107ffa373 rb_gc_mark_machine_stack + 99
5   ruby                                0x000000010814ae09 rb_execution_context_mark + 137
6   ruby                                0x0000000107fc8b0b cont_mark + 27
7   ruby                                0x0000000108003a22 gc_start + 2434
8   ruby                                0x0000000108002f1f newobj_slowpath + 1055
9   ruby                                0x0000000108002ad4 newobj_slowpath_wb_protected + 20
10  ruby                                0x00000001080ed99e rb_str_inspect + 94

Is this running in parallel by any chance?

out of curiosity, here's some aggressive GC running refed in https://github.com/ko1/nakayoshi_fork/blob/master/lib/nakayoshi_fork.rb

SimpleCov::SourceFile.class_eval do
  def project_filename
      h = {}
      4.times{ # maximum 4 times
        GC.stat(h)
        live_slots = h[:heap_live_slots] || h[:heap_live_slot]
        old_objects = h[:old_objects] || h[:old_object]
        remwb_unprotects = h[:remembered_wb_unprotected_objects] || h[:remembered_shady_object]
        young_objects = live_slots - old_objects - remwb_unprotects

        # p [[live_slots, old_objects, remwb_unprotects], [young_objects]]

        break if young_objects < live_slots / 10

        disabled = GC.enable
        GC.start(full_mark: false)
        GC.disable if disabled
      }
    p [:debug, @filename, SimpleCov.root]
     @filename.sub(/^#{SimpleCov.root}/, "")
  end
end

@chrismanderson
Copy link
Author

  1. The last line output by doing
1 SimpleCov::SourceFile.class_eval do
2  def project_filename
3    p [:debug, @filename]
4    p [:debug,   SimpleCov.root]
5    File.basename(Dir.pwd)
6  end
7 end

is random, which is always fun . Sometimes is segfaults on line 5, sometimes on 3. Sometimes it makes it through the debugs but then segfaults in simplecov (what's references

I did have .bundle filtered, and added your list of filters to my .simplecov file but they still appear in the debug output.

I then ran your GC code above and I think you might be right that it is GC. In this case the segfault occurred at GC.start(full_mark: false).

Finished in 14.645760s, 17.6843 runs/s, 32.5009 assertions/s.
259 runs, 476 assertions, 0 failures, 0 errors, 0 skips
/Users/chris/galley/admin/test/test_helper.rb:18: [BUG] Segmentation fault at 0x000070000a51d4b0
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

-- 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:0017 p:---- s:0080 e:000079 CFUNC  :start
c:0016 p:0130 s:0075 e:000074 BLOCK  /Users/chris/galley/admin/test/test_helper.rb:18 [FINISH]
c:0015 p:---- s:0067 e:000066 CFUNC  :times
c:0014 p:0010 s:0063 e:000062 METHOD /Users/chris/galley/admin/test/test_helper.rb:6
c:0013 p:0005 s:0058 e:000057 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52
c:0012 p:0008 s:0053 e:000052 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0011 p:---- s:0049 e:000048 CFUNC  :reject
c:0010 p:0007 s:0045 e:000044 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111 [FINISH]
c:0009 p:---- s:0041 e:000040 CFUNC  :each
c:0008 p:0015 s:0037 e:000036 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110
c:0007 p:0014 s:0031 e:000030 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83
c:0006 p:0042 s:0027 e:000026 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC  :new
c:0004 p:0049 s:0017 e:000016 METHOD /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82
c:0003 p:0011 s:0013 e:000012 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180 [FINISH]
c:0002 p:0095 s:0010 e:000009 BLOCK  /Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68 [FINISH]
c:0001 p:0000 s:0003 E:0010e0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/defaults.rb:68:in `block in <top (required)>'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/configuration.rb:180:in `block in at_exit'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82:in `result'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:82:in `new'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:31:in `initialize'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/result.rb:83:in `filter!'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110:in `filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:110:in `each'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `block in filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `reject'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov.rb:111:in `block (2 levels) in filtered'
/Users/chris/galley/admin/.bundle/gems/simplecov-0.15.1/lib/simplecov/filter.rb:52:in `matches?'
/Users/chris/galley/admin/test/test_helper.rb:6:in `project_filename'
/Users/chris/galley/admin/test/test_helper.rb:6:in `times'
/Users/chris/galley/admin/test/test_helper.rb:18:in `block in project_filename'
/Users/chris/galley/admin/test/test_helper.rb:18:in `start'

And crash report is attached.
ruby_2018-02-01-164549_Blackbriar.txt

@bf4
Copy link
Collaborator

bf4 commented Feb 1, 2018

@chrismanderson How far do you think we can go before filing a bug report in Ruby? Need to find a minimal case.

Can you move your bundle dir elsewhere? cat .bundle/config and I'm guessing there's a config in there that is setting your bundle path to local. In any case, you could rm -rf .bundle and then bundle --path ../galley_bundle or something like that. Then try removing all your tests except for one, and see if it fails again, then keep adding them. Or see what you get from bundle config --list or bundle config --local or bundle config --global. does bundle doctor say anything interesting?

Maybe also try uncommenting # p [[live_slots, old_objects, remwb_unprotects], [young_objects]] in case it has useful info

What OSX version are you on? Is this only happening on your machine?

Do you have any gems with C-extensions? Or have you using jemalloc or anything?

I see


Exception Type:        EXC_BAD_ACCESS (SIGABRT)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00007000036cc4b0
Exception Note:        EXC_CORPSE_NOTIFY

VM Regions Near 0x7000036cc4b0:
    Stack                  00007000033c0000-00007000033c6000 [   24K] rw-/rwx SM=COW  thread 1
--> 
    MALLOC_TINY            00007f

looks suspicious, but I don't know much about it.

I can see from the stack trace that the code is being called in a block.

Do you have timeout running somewhere?

How did you install your ruby? did you have to install libgmp yourself?

what is ruby -e 'puts RUBY_DESCRIPTION' or type ruby. Anything interesting show up in ruby -rrbconfig -rpp -e 'pp RbConfig::CONFIG'? like for CC or CX gcc --version or g++ --version?

Is it possible you're running out of disk space with too many open files?

@bf4
Copy link
Collaborator

bf4 commented Feb 1, 2018

there were coverage changes https://bugs.ruby-lang.org/issues/13901 ... but I believe you confirmed that ignoring simplecov and just using the Coverage lib was fine

require 'pp'
require 'coverage'
Coverage.start
at_exit { pp Coverage.result }

@chrismanderson
Copy link
Author

chrismanderson commented Feb 1, 2018

Hey so this is a fun discovery, removed simplecov added in

require 'pp'
require 'coverage'
Coverage.start
at_exit { pp Coverage.result }

and got a segfault.

Ran the suite a few more times, and got 8 segfaults and 2 runs that completed WITHOUT a segfault.

So clearly seems to be a Ruby bug and likely something with GC that causes inconsistent results. Will open up a Ruby issue.

[nil,/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:311: [BUG] Segmentation fault at 0x000070000b0314b0
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

-- 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:0062 p:0002 s:0301 e:000300 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:311 [FINISH]
c:0061 p:---- s:0297 e:000296 CFUNC  :new
c:0060 p:0069 s:0293 e:000292 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:187
c:0059 p:0033 s:0286 e:000285 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:250
c:0058 p:0035 s:0277 e:000276 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161
c:0057 p:0009 s:0271 e:000270 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:333
c:0056 p:0023 s:0267 e:000266 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:224 [FINISH]
c:0055 p:---- s:0263 e:000262 CFUNC  :each
c:0054 p:0034 s:0259 E:0016b0 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:218
c:0053 p:0008 s:0251 E:000b30 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:332
c:0052 p:0003 s:0248 e:000247 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253
c:0051 p:0013 s:0245 e:000244 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280
c:0050 p:0008 s:0240 e:000239 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252
c:0049 p:0045 s:0237 e:000236 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265
c:0048 p:0039 s:0232 e:000231 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251
c:0047 p:0011 s:0223 E:0008c8 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:331
c:0046 p:0007 s:0218 e:000217 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161
c:0045 p:0003 s:0215 e:000214 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253
c:0044 p:0013 s:0212 e:000211 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280
c:0043 p:0008 s:0207 e:000206 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252
c:0042 p:0045 s:0204 e:000203 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265
c:0041 p:0039 s:0199 e:000198 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251
c:0040 p:0035 s:0190 e:000189 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161
c:0039 p:0015 s:0184 e:000183 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:253
c:0038 p:0003 s:0181 e:000180 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253
c:0037 p:0013 s:0178 e:000177 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280
c:0036 p:0008 s:0173 e:000172 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252
c:0035 p:0045 s:0170 e:000169 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265
c:0034 p:0039 s:0165 e:000164 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251
c:0033 p:0021 s:0156 e:000155 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:251
c:0032 p:0003 s:0153 e:000152 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253
c:0031 p:0013 s:0150 e:000149 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280
c:0030 p:0008 s:0145 e:000144 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252
c:0029 p:0045 s:0142 e:000141 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265
c:0028 p:0039 s:0137 e:000136 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251
c:0027 p:0006 s:0128 e:000127 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:248
c:0026 p:0023 s:0123 e:000122 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:224 [FINISH]
c:0025 p:---- s:0119 e:000118 CFUNC  :each_pair
c:0024 p:0034 s:0115 E:001dd0 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:218
c:0023 p:0011 s:0107 E:0019e0 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:247
c:0022 p:0003 s:0104 e:000103 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253
c:0021 p:0013 s:0101 e:000100 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280
c:0020 p:0008 s:0096 e:000095 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252
c:0019 p:0045 s:0093 e:000092 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265
c:0018 p:0039 s:0088 e:000087 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251
c:0017 p:0010 s:0079 E:0017a8 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:246
c:0016 p:0006 s:0074 e:000073 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:345
c:0015 p:0007 s:0069 e:000068 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161
c:0014 p:0003 s:0066 e:000065 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253
c:0013 p:0013 s:0063 e:000062 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280
c:0012 p:0008 s:0058 e:000057 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252
c:0011 p:0045 s:0055 e:000054 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265
c:0010 p:0039 s:0050 e:000049 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251
c:0009 p:0035 s:0041 e:000040 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161
c:0008 p:0008 s:0035 e:000034 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:73
c:0007 p:0144 s:0032 e:000031 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:120
c:0006 p:0030 s:0027 e:000026 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:73
c:0005 p:0013 s:0019 e:000018 BLOCK  /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:554 [FINISH]
c:0004 p:---- s:0015 e:000014 CFUNC  :each
c:0003 p:0006 s:0011 e:000010 METHOD /Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:553
c:0002 p:0015 s:0006 e:000005 BLOCK  /Users/chris/galley/admin/test/test_helper.rb:9 [FINISH]
c:0001 p:0000 s:0003 E:0013c0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/chris/galley/admin/test/test_helper.rb:9:in `block in <top (required)>'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:553:in `pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:553:in `each'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:554:in `block in pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:73:in `pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:120:in `guard_inspect_key'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:73:in `block in pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161:in `pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251:in `group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265:in `group_sub'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252:in `block in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280:in `nest'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253:in `block (2 levels) in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161:in `block in pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:345:in `pretty_print'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:246:in `pp_hash'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251:in `group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265:in `group_sub'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252:in `block in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280:in `nest'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253:in `block (2 levels) in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:247:in `block in pp_hash'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:218:in `seplist'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:218:in `each_pair'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:224:in `block in seplist'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:248:in `block (2 levels) in pp_hash'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251:in `group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265:in `group_sub'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252:in `block in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280:in `nest'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253:in `block (2 levels) in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:251:in `block (3 levels) in pp_hash'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251:in `group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265:in `group_sub'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252:in `block in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280:in `nest'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253:in `block (2 levels) in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:253:in `block (4 levels) in pp_hash'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161:in `pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251:in `group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265:in `group_sub'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252:in `block in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280:in `nest'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253:in `block (2 levels) in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161:in `block in pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:331:in `pretty_print'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:251:in `group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:265:in `group_sub'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:252:in `block in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:280:in `nest'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:253:in `block (2 levels) in group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:332:in `block in pretty_print'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:218:in `seplist'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:218:in `each'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:224:in `block in seplist'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:333:in `block (2 levels) in pretty_print'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/pp.rb:161:in `pp'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:250:in `group'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:187:in `text'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:187:in `new'
/Users/chris/.rbenv/versions/2.5.0/lib/ruby/2.5.0/prettyprint.rb:311:in `initialize'

-- C level backtrace information -------------------------------------------
0   ruby                                0x000000010f966da7 rb_vm_bugreport + 135
1   ruby                                0x000000010f7ebe08 rb_bug_context + 472
2   ruby                                0x000000010f8db361 sigsegv + 81
3   libsystem_platform.dylib            0x00007fff7883df5a _sigtramp + 26
4   ruby                                0x000000010f805373 rb_gc_mark_machine_stack + 99
5   ruby                                0x000000010f955e09 rb_execution_context_mark + 137
6   ruby                                0x000000010f7d3b0b cont_mark + 27
7   ruby                                0x000000010f80ea91 gc_start + 2545
8   ruby                                0x000000010f80df1f newobj_slowpath + 1055
9   ruby                                0x000000010f80dad4 newobj_slowpath_wb_protected + 20
10  ruby                                0x000000010f77b6b2 ary_new + 66
11  ruby                                0x000000010f77b979 rb_ary_tmp_new_from_values + 25
12  ruby                                0x000000010f94a9db vm_exec_core + 40955
13  ruby                                0x000000010f954b5e vm_exec + 142
14  ruby                                0x000000010f9620c8 rb_call0 + 152
15  ruby                                0x000000010f94d3a1 rb_funcallv + 49
16  ruby                                0x000000010f8599d9 rb_class_s_new + 41
17  ruby                                0x000000010f95a28e vm_call_cfunc + 286
18  ruby                                0x000000010f9439c4 vm_exec_core + 12260
19  ruby                                0x000000010f954b5e vm_exec + 142
20  ruby                                0x000000010f962284 invoke_block_from_c_bh + 372
21  ruby                                0x000000010f94fe7e rb_yield + 158
22  ruby                                0x000000010f77db49 rb_ary_each + 41
23  ruby                                0x000000010f95a28e vm_call_cfunc + 286
24  ruby                                0x000000010f95b28b vm_call_opt_send + 587
25  ruby                                0x000000010f942f34 vm_exec_core + 9556
26  ruby                                0x000000010f954b5e vm_exec + 142
27  ruby                                0x000000010f962284 invoke_block_from_c_bh + 372
28  ruby                                0x000000010f94fe7e rb_yield + 158
29  ruby                                0x000000010f81aee1 each_pair_i + 17
30  ruby                                0x000000010f81a171 hash_foreach_iter + 33
31  ruby                                0x000000010f8e4af6 st_general_foreach + 662
32  ruby                                0x000000010f8132f2 hash_foreach_call + 34
33  ruby                                0x000000010f7f64a1 rb_ensure + 193
34  ruby                                0x000000010f816cba rb_hash_each_pair + 154
35  ruby                                0x000000010f95a28e vm_call_cfunc + 286
36  ruby                                0x000000010f95b28b vm_call_opt_send + 587
37  ruby                                0x000000010f942f34 vm_exec_core + 9556
38  ruby                                0x000000010f954b5e vm_exec + 142
39  ruby                                0x000000010f962284 invoke_block_from_c_bh + 372
40  ruby                                0x000000010f94fe7e rb_yield + 158
41  ruby                                0x000000010f77db49 rb_ary_each + 41
42  ruby                                0x000000010f95a28e vm_call_cfunc + 286
43  ruby                                0x000000010f942f34 vm_exec_core + 9556
44  ruby                                0x000000010f954b5e vm_exec + 142
45  ruby                                0x000000010f95363e vm_invoke_proc + 238
46  ruby                                0x000000010f888dc1 rb_proc_call + 81
47  ruby                                0x000000010f7f4df7 rb_exec_end_proc + 423
48  ruby                                0x000000010f7f53c2 ruby_finalize_0 + 130
49  ruby                                0x000000010f7f550f ruby_cleanup + 303
50  ruby                                0x000000010f7f57df ruby_run_node + 63
51  ruby                                0x000000010f77b01f main + 79

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

@PragTob
Copy link
Collaborator

PragTob commented Feb 2, 2018

👋 @bf4 we already have a bug filed with ruby-lang. Thanks for all the debugging help! https://bugs.ruby-lang.org/issues/14334

@chrismanderson
Copy link
Author

Depending on how that issue goes I might open up a new bug on ruby-lang now that I have a case that does not require simplecov at all. Going to see over the weekend too to get a sample project that recreates the issue as well. Always fun finding Ruby bugs!

@PragTob
Copy link
Collaborator

PragTob commented Feb 2, 2018

Yeah I updated the issue detailing that it's not related to simplecov and even if it'd be we don't have a c-extension - no way client ruby code should be able to cause a segfault.

@dazuma
Copy link

dazuma commented Feb 28, 2018

We were running into this segfault also (googleapis/google-cloud-ruby#1979) and were able to narrow it down. See https://bugs.ruby-lang.org/issues/14561

@PragTob
Copy link
Collaborator

PragTob commented Mar 1, 2018

Thanks for doing that! Fingers crossed for a patch release!

I'll close this issue though, there's nothing we can do than assure ruby-core this is a problem...

@PragTob PragTob closed this as completed Mar 1, 2018
@sebasjimenez10
Copy link

Hey guys, I recently came across this same issue, running SimpleCov version 0.16.1 and Rails 5.1.5 and RSpec 3.7.

I noticed that every time I wanted to run coverage locally it crashed with the SegFault metioned above... After trying to solve that issue I noticed that if I moved the SimpleCov config block from the spec_helper.rb to the rails_helper.rb it wouldn't crash, and that's what I'm using ever since.

Hope this is useful.

@topaz2
Copy link

topaz2 commented Sep 28, 2018

@sebasjimenez10 You saved my day ;)

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

6 participants