Articles

Ruby SassC Illegal Instruction

We encountered a rare issue the other day when deploying one of our Ruby on Rails 5 applications. Our deployments suddenly started failing with a massive 1600 lines of Ruby level backtrace information!

Here is an excerpt from our error log:

/usr/local/bundle/gems/ffi-1.11.1/lib/ffi/library.rb:112: [BUG] Illegal instruction at 0x00007f614aa991a5
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux-musl]
-- Control frame information -----------------------------------------------
c:0120 p:---- s:0685 e:000684 CFUNC  :open
c:0119 p:0022 s:0679 e:000678 BLOCK  /usr/local/bundle/gems/ffi-1.11.1/lib/ffi/library.rb:112 [FINISH]
c:0118 p:---- s:0670 e:000669 CFUNC  :each
c:0117 p:0113 s:0666 e:000665 BLOCK  /usr/local/bundle/gems/ffi-1.11.1/lib/ffi/library.rb:109 [FINISH]
c:0116 p:---- s:0659 e:000658 CFUNC  :map
c:0115 p:0069 s:0655 e:000654 METHOD /usr/local/bundle/gems/ffi-1.11.1/lib/ffi/library.rb:99
c:0114 p:0079 s:0648 e:000647 CLASS  /usr/local/bundle/gems/sassc-2.2.1/lib/sassc/native.rb:11
c:0113 p:0007 s:0644 e:000643 CLASS  /usr/local/bundle/gems/sassc-2.2.1/lib/sassc/native.rb:6
c:0112 p:0014 s:0641 e:000640 TOP    /usr/local/bundle/gems/sassc-2.2.1/lib/sassc/native.rb:5 [FINISH]
...
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: https://www.ruby-lang.org/bugreport.html
Aborted (core dumped)

A crew member eventually discovered issue #146 in the sassc-ruby project which was caused by the precompiled gem no longer being portable between different processor architectures.

This is a particular problem for us in this project because we use AWS CodeBuild to build our rails app docker image, which is then deployed to ECS.

The Solution

Until this is resolved in the sassc-ruby project we have added the following to our Dockerfile before our bundle install:

RUN bundle config --local build.sassc --disable-march-tune-native

And now we can resume happy deployments!