Reputation: 167
I'm running a system test in a Rails app on a MacBook M1 Big Sur OS and it's giving me a segmentation fault error.
I'm using Ruby 2.7.1 installed via rbenv
➜ which ruby
/Users/sc/.rbenv/shims/ruby
➜ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [-darwin20]
Now, the issue comes whenever I run a rails system test. Our system tests are congigured with the headless_chrome Capybara driver, which has probably (not sure about this) something to do with the segmentation fault error.
This is what I get when I run the test:
[BUG] Segmentation fault at 0x000000001b543e20
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [-darwin20]
-- 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:0001 p:---- s:0003 e:000002 (none) [FINISH]
-- Other runtime information -----------------------------------------------
* Loaded script: rails_test
* Loaded features:
0 enumerator.so
1 thread.rb
2 rational.so
3 complex.so
4 ruby2_keywords.rb
5 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/-darwin20/enc/encdb.bundle
6 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/-darwin20/enc/trans/transdb.bundle
7 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/-darwin20/rbconfig.rb
8 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/compatibility.rb
9 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/defaults.rb
10 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/deprecate.rb
And many more lines...
Any ideas on what's causing this error?
Upvotes: 6
Views: 2949
Reputation: 325
This happens because of a bug in Enumerator#next
, happening in ruby 2.7.1 on Apple M1. Capybara uses it in Capybara::Result class.
The simpleset irb snippet to ensure this is your case is [1,2,3].to_enum.next
:
irb(main):003:0> [1,2,3].to_enum.next
[BUG] Segmentation fault at 0x0000000004809020
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [-darwin20]
The best solution is to upgrade ruby version to 2.7.3, which does not have this bug.
(If you need to run the tests quickly and solve the core problem later, you can edit capybara's result.rb locally, as a stupid temporary workaround. But I strongly recommend to upgrade ruby version asap)
UPD: I have posted a bug report in a ruby bug tracker.
Upvotes: 10
Reputation: 29
I ran into the same problem when running my tests. I was helped by the Ruby update to 2.7.3
Upvotes: 1