DEV Community

Ruby Segmentation Fault When Running RSpec

Andy Zhao (he/him) on June 29, 2018

So I've been getting this segmentation fault error, which from what I've been hearing and reading it's a low-level Ruby error. It happens when I ru...
Collapse
 
katafrakt profile image
Paweł Świątkowski

It's really hard to tell. In my experience segmentation faults usually happen when there is something wrong with some C extension in some gem. But in your case it seems to come straight from Ruby core lib. Someone might have better idea, but to me it seems like one of those:

  • There is a problem with your Ruby installation (unlikely)
  • Some gem you used accessed some memory it should not, hence this odd backtrace – maybe post your Gemfile
  • Some other program running on your computer messed up something in memory

Not sure if that helps, but that's all I can think of at the moment.

Collapse
 
andy profile image
Andy Zhao (he/him)

Definitely helpful, thanks for the insight. I did reinstall my Ruby and rbenv recently to test something, and ever since then I've been getting that error.

I'm a bit skeptical about this, but it might also be because I upgraded my Mac to High Sierra...

Collapse
 
katafrakt profile image
Paweł Świątkowski

MacOS is actually notorious for breaking Ruby-related things on every upgrade, so you might be on to something. Just last week my colleague had to reinstall his system completely in order to make Ruby working again. He had other symptoms though, as far as I remember (something SSL-related).

Thread Thread
 
andy profile image
Andy Zhao (he/him)

Yikes. I'm going to be wiping my drive anyway, so while drastic, it might solve my issues. Maybe 2.5.1 will fare better with High Sierra, too.

Collapse
 
hoelzro profile image
Rob Hoelz

I don't have a ton of experience with Ruby, but I've seen this when using rbenv when a library that Ruby was compiled against a library that has been updated. I would try building a fresh rbenv installation of the same Ruby version and see if that fixes the issue; if not feel free to ping me and I'll help you work through it!

Collapse
 
rhymes profile image
rhymes

The first thing I would try is to see if the issue is still there on Ruby 2.5.1.

Does it happen only with rspec?

Collapse
 
andy profile image
Andy Zhao (he/him)

Yeah pretty much. I never hit it when running rails server or any other Ruby/Rails commands.

Collapse
 
tamouse profile image
Tamara Temple

I'm seeing a segfault when I try to bisect a series of tests. I'm already running 2.5.1. Running rspec without the bisect works fine.

Collapse
 
andy profile image
Andy Zhao (he/him) • Edited

Hmm that's interesting. What's bisecting? Is that the default that comes with running the rspec command? I'm using a bin command that's runs plain rspec, and now that I think about it I haven't tried running the entire test suite in guard.

Edit: No luck in guard, and judging from our bin/rspec command, doesn't seem like we are bisecting either. The investigation continues...

Collapse
 
tamouse profile image
Tamara Temple

rspec bisect is so very cool. let's say running in CI, you had some failures, and you want to find out if they happen to be order-dependent, or if there's a root of something failing. You pass the test command, with the seed the tests were run with and the --bisect command, and rspec will find the minimal set of tests that need to run in order to reproduce the set of failures; hopefully winnowing down where the actual failure is coming from! Definitely a useful part of the rspec toolbelt

Collapse
 
andy profile image
Andy Zhao (he/him)

Thanks, seems like upgrading is the easiest and best option.