sassc-ruby: Segmentation fault when precompiling assets
Sometimes, when I make some changes to my .scss
files in my Rails 6 app, I get the following when running rails assets:precompile

And also, when deploying to Heroku, I get
rubyDone in 4.85s. remote: /tmp/build_929254ebef3a89a9f40b4b26f007bde3/vendor/bundle/ruby/2.7.0/gems/sassc-2.3.0/lib/sassc/engine.rb:43: [BUG] Segmentation fault at 0x0000000000000000 remote: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] -- Control frame information ----------------------------------------------- remote: c:0059 p:---- s:0449 e:000448 CFUNC :compile_data_context remote: c:0058 p:0314 s:0444 e:000443 METHOD /tmp/build_c5dc2802730effed8a887745a1195bb5/vendor/bundle/ruby/2.7.0/gems/sassc-2.3.0/lib/sassc/engine.rb:43
along with Aborted. remote: ! Precompiling assets failed.
and it won’t do the deployment successfully. I keep getting
remote:
remote: Aborted
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected
I don’t get any other errors, so I think it’s merely related to that compilation thing. I tried upgrading & downgrading the version of the gem but still can’t get it through. I’ve been having this problem a while ago now and it had been sort of random, it wouldn’t show up always, but recently, I get it almost every time I make a CSS change.
Can anybody help me out here? Thanks a lot in advance.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 41
- Comments: 21
Commits related to this issue
- Avoid sprocket building assets concurrently This is a temporary fix until https://github.com/sass/sassc-ruby/issues/207 is resolved This should stop the segfault from happening upon deploy — committed to OfficeForProductSafetyAndStandards/product-safety-database by StupidCodeFactory 4 years ago
- Avoid sprocket building assets concurrently (#1004) This is a temporary fix until https://github.com/sass/sassc-ruby/issues/207 is resolved This should stop the segfault from happening upon deplo... — committed to OfficeForProductSafetyAndStandards/product-safety-database by StupidCodeFactory 4 years ago
- CI: fix the build **What** * Update the CI configuration for Rubocop to install the same version that is specified in `Gemfile.lock`. I think it might be better to run `bundle` instead of instal... — committed to EBWiki/EBWiki by mockdeep 3 years ago
- CI: fix Sprockets issues **What** * Introduce `app/assets/config/manifest.js`. Sprockets was [recently upgraded][upgrade] to version 4, but [it now requires this file][file] to exist in order to... — committed to EBWiki/EBWiki by mockdeep 3 years ago
- CI: fix Sprockets issues **What** * Introduce `app/assets/config/manifest.js`. Sprockets was [recently upgraded][upgrade] to version 4, but [it now requires this file][file] to exist in order to... — committed to EBWiki/EBWiki by mockdeep 3 years ago
- CI: fix the build **What** * Update the CI configuration for Rubocop to install the same version that is specified in `Gemfile.lock`. I think it might be better to run `bundle` instead of instal... — committed to EBWiki/EBWiki by mockdeep 3 years ago
- CI: fix the build **What** * Update the CI configuration for Rubocop to install the same version that is specified in `Gemfile.lock`. I think it might be better to run `bundle` instead of instal... — committed to EBWiki/EBWiki by mockdeep 3 years ago
- CI: fix Sprockets issues **What** * Introduce `app/assets/config/manifest.js`. Sprockets was [recently upgraded][upgrade] to version 4, but [it now requires this file][file] to exist in order to... — committed to EBWiki/EBWiki by mockdeep 3 years ago
- CI: fix Sprockets issues (#3885) **What** * Introduce `app/assets/config/manifest.js`. Sprockets was [recently upgraded][upgrade] to version 4, but [it now requires this file][file] to exist... — committed to EBWiki/EBWiki by mockdeep 3 years ago
- Use sprockets version 3.7.2 Various suggestions to downgrade sprockets to fix a segfault crash: https://github.com/sass/sassc-ruby/issues/207 https://github.com/sass/sassc-rails/issues/122 https://g... — committed to Iridescent-CM/technovation-app by shaun-technovation 3 years ago
- Use sprockets version 3.7.2 Various suggestions to downgrade sprockets to fix a segfault crash: https://github.com/sass/sassc-ruby/issues/207 https://github.com/sass/sassc-rails/issues/122 https://g... — committed to Iridescent-CM/technovation-app by shaun-technovation 3 years ago
- Ne build pas les assets en mode concurent https://github.com/sass/sassc-ruby/issues/207#issuecomment-674626874 — committed to betagouv/eva-serveur by cprodhomme 3 years ago
- Disable Sprockets/sassc concurrency We've been seeing (more regular) test failures due to sassc concurrency issues. This should disable concurrency with Sprockets, as suggested on the `sassc-ruby` pr... — committed to thoughtbot/administrate by nickcharlton 2 years ago
- Disable Sprockets/sassc concurrency We've been seeing (more regular) test failures due to sassc concurrency issues. This should disable concurrency with Sprockets, as suggested on the `sassc-ruby` pr... — committed to thoughtbot/administrate by nickcharlton 2 years ago
- Try this one trick to remove seg faults From: https://github.com/sass/sassc-ruby/issues/207 — committed to alphagov/govuk_publishing_components by kevindew 2 years ago
- Try this one trick to remove seg faults Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per https://github.com/rails/sprock... — committed to alphagov/govuk_publishing_components by kevindew 2 years ago
- Try this one trick to remove seg faults Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per https://github.com/rails/sprock... — committed to alphagov/govuk_publishing_components by kevindew 2 years ago
- Try this one trick to remove seg faults Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per https://github.com/rails/sprock... — committed to alphagov/govuk_publishing_components by kevindew 2 years ago
- Try this one trick to remove seg faults Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per https://github.com/rails/sprock... — committed to alphagov/govuk_publishing_components by kevindew 2 years ago
- Try this one trick to remove seg faults Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per https://github.com/rails/sprock... — committed to alphagov/govuk_publishing_components by kevindew 2 years ago
Yes, that’s same as doing
in the
application.rb
, but not always works.I saw something very similar after upgrading an older app to Sprockets 4, which introduced concurrent asset compilation. I’m guessing that something within sassc-ruby or libsass isn’t thread-safe.
The problem goes away (for me) with
Sprockets.export_concurrent = false
in an initializer.I had the same issue on Intel Mac using Ruby 2.7.4, Rails 5.0.7.1, Sprockets 3.7.1, sassc 2.0.1, ffi 1.14.2, and libffi 3.4.2.
For me, only updating ffi gem to 1.15.4 fixed the issue. It seems the issue was triggered by a subtle incompatibility among libffi, ffi gem, and sassc native ext.
I believe I’m seeing the same thing while running tests on CircleCI. My test suite runs fine until it hits my integration tests which compile assets.
I’ve tried with these combos: ruby 2.6.6 & sassc 2.4.0 ruby 2.6.6 & sassc 2.3.0
Test output:
@stevenwilliamson I am sympathetic!
I’ve been trying to figure out how to reduce the number of dependencies that I use in Rails, and this is an example of why… I’m maintaining an app that is 8 years old now, and it’s a reminder that while my app may not change, the architectures under it are constantly evolving…
I have created an example app that reproduces this problem: https://github.com/mvz/example-app-sprockets-crash
I was having a similar problem to @rlgreen91, my tests were also failing… And I found that the problem was in my code…
I was
@import
ing a file from a dependency that I was just removed. After I removed the@import
the segmentation fault was gone… It was not the best error message jeje, but the error was in my code.… So if you are reading this thread, because you have a similar error, maybe your problem could also be a bad
@import
.I use sass-rails, but stumbled on the same issue after upgrading ruby from 2.7.2 to 2.7.5, using rails 6.0.4.6 and sass-rails 6.0.0. Deleting everything from the assets folder (except config/manifest.js) did not help.
The problem vanished after I downgraded sass-rails to the newest 5.x version (5.1.0). I also had to downgrade sprockets from 4.0.3 to 3.7.2, because sass-rails 5.1.0 requires sprockets version <4.
Just adding another comment saying that disabling the concurrent mode fixes the issue for me. Basically, I did this:
So I can run the tests in my CI job.
I think we can close this issue because this is an issue with Sprockets, not with
sassc-ruby
.I can reproduce the crash with Sprockets v3.7.2 and confirmed that it was indeed a thread-safety issue that has now been fixed in Sprockets v4.2.0 via https://github.com/rails/sprockets/pull/759. Those of you having trouble might want to upgrade to v4.2.1. I’m not sure if
Sprockets.export_concurrent
is still needed, but it might be.In GitLab, we use Sidekiq to run background jobs to send notification e-mails. I can easily reproduce a seg fault by:
rm -rf tmp/cache/assets/sprockets/v3.0
.I believe this was happening:
When multiple Sidekiq jobs attempt to render SCSS in notification e-mails, Sprockets invokes
SassC::Rails::SassTemplate.call
on a singleton object viaprocessor_utils.rb
.Sprockets::Utils.module_include
was previously not thread-safe, so the SASS functions list passed to libsass would be corrupted by one thread.When libasss attempted to look up a SASS function, it would hit a seg fault if the function it needed wasn’t in the list.
The following contains the Ruby and C backtrace:
I got this on sassc-2.4.0 and ruby-2.7.0
We are seeing the same problem segfault in the compile_data_context function. It is intermittent and we do not hit it every build but we tend to see the issue in CI when tests are running and Rails is compiling assets on the fly.
It does not look like there has been a commit to this repo for over a year, is this gem still active gem, is it deprecated, is it in maintenance, EOL?
It’s not clear from looking at the Git repo if this is an active project or not, should we be using something else etc ?
@bhserna your commented fixed my problem! Thhank you!