-
Notifications
You must be signed in to change notification settings - Fork 158
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
Segmentation fault when precompiling assets #207
Comments
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: Test output:
|
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 |
Yes, that's same as doing
in the |
I'm having the same crash in development mode for an app that was recently upgraded to Sprockets 4 (Ruby 2.6.6, Rails 6.0.3). It's a random thing but happens very often. Disabling concurrent asset compilation fixed the issue for me. |
This is a temporary fix until sass/sassc-ruby#207 is resolved This should stop the segfault from happening upon deploy
This is a temporary fix until sass/sassc-ruby#207 is resolved This should stop the segfault from happening upon deploy
**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 installing `rubocop` directly, but it will be good to set up caching to reduce performance overhead. * Downcase `PWD`. I'm guessing these files were developed on a file system that is not case sensitive. Linux, on the other hand, is. * Introduce `config/manifest.js`. Sprockets throws an error when trying to boot the server. It now requires this file to exist, I believe as of version 4.0. I'm guessing this issue started in #3797. * Disable Rollbar in dev/test mode. * Update CodeClimate in `Makefile` to use [the `shell` keyword][shell]. `pwd` was returning nothing, so it wasn't able to properly find the config file. * Disable concurrent exports for Sprockets. It has a tendency to [cause segfaults][seg] in Ruby, making builds (and deploys) super flaky. [shell]: https://stackoverflow.com/a/18137056/372479 [seg]: sass/sassc-ruby#207
**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 determine which files to compile. * Disable concurrent exports for Sprockets. It has a tendency to [cause segfaults][segfault] in Ruby, making builds (and deploys) super flaky. I've already seen it fail a few times working on getting the build passing. [upgrade]: #3797 [file]: https://github.com/rails/sprockets/blob/master/UPGRADING.md#manifestjs [segfault]: sass/sassc-ruby#207
**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 determine which files to compile. * Disable concurrent exports for Sprockets. It has a tendency to [cause segfaults][segfault] in Ruby, making builds (and deploys) super flaky. I've already seen it fail a few times working on getting the build passing. [upgrade]: #3797 [file]: https://github.com/rails/sprockets/blob/master/UPGRADING.md#manifestjs [segfault]: sass/sassc-ruby#207
**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 installing `rubocop` directly, but it will be good to set up caching to reduce performance overhead. * Downcase `PWD`. I'm guessing these files were developed on a file system that is not case sensitive. Linux, on the other hand, is. * Introduce `config/manifest.js`. Sprockets throws an error when trying to boot the server. It now requires this file to exist, I believe as of version 4.0. I'm guessing this issue started in #3797. * Disable Rollbar in dev/test mode. * Update CodeClimate in `Makefile` to use [the `shell` keyword][shell]. `pwd` was returning nothing, so it wasn't able to properly find the config file. * Disable concurrent exports for Sprockets. It has a tendency to [cause segfaults][seg] in Ruby, making builds (and deploys) super flaky. [shell]: https://stackoverflow.com/a/18137056/372479 [seg]: sass/sassc-ruby#207
**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 installing `rubocop` directly, but it will be good to set up caching to reduce performance overhead. * Downcase `PWD`. I'm guessing these files were developed on a file system that is not case sensitive. Linux, on the other hand, is. * Introduce `config/manifest.js`. Sprockets throws an error when trying to boot the server. It now requires this file to exist, I believe as of version 4.0. I'm guessing this issue started in #3797. * Disable Rollbar in dev/test mode. * Update CodeClimate in `Makefile` to use [the `shell` keyword][shell]. `pwd` was returning nothing, so it wasn't able to properly find the config file. * Disable concurrent exports for Sprockets. It has a tendency to [cause segfaults][seg] in Ruby, making builds (and deploys) super flaky. [shell]: https://stackoverflow.com/a/18137056/372479 [seg]: sass/sassc-ruby#207
**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 determine which files to compile. * Disable concurrent exports for Sprockets. It has a tendency to [cause segfaults][segfault] in Ruby, making builds (and deploys) super flaky. I've already seen it fail a few times working on getting the build passing. [upgrade]: #3797 [file]: https://github.com/rails/sprockets/blob/master/UPGRADING.md#manifestjs [segfault]: sass/sassc-ruby#207
**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 determine which files to compile. * Disable concurrent exports for Sprockets. It has a tendency to [cause segfaults][segfault] in Ruby, making builds (and deploys) super flaky. I've already seen it fail a few times working on getting the build passing. [upgrade]: #3797 [file]: https://github.com/rails/sprockets/blob/master/UPGRADING.md#manifestjs [segfault]: sass/sassc-ruby#207
I'm seeing the same issues in our app, which uses Ruby 2.6.6 and Rails 5.0.7. The gem is at the most recent version, 2.4.0. This also occurred after an update to Sprockets 4. The recommended solution of disabling concurrent asset compilation does not work when running our test suite locally. |
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 ... So if you are reading this thread, because you have a similar error, maybe your problem could also be a bad |
@bhserna your commented fixed my problem! Thhank you! |
I have created an example app that reproduces this problem: https://github.com/mvz/example-app-sprockets-crash |
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 ? |
@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... |
We get the same error using Ruby 2.5.8 or 2.7.2 with rails 5.0.7.2, Sassc 2.4.0 and Sprockets 4.0. |
Also having similar issue: |
For any one still got this issue
Then it's work. |
Various suggestions to downgrade sprockets to fix a segfault crash: sass/sassc-ruby#207 sass/sassc-rails#122 rails/sprockets#633 We'll see if that fixes it for us. Refs: #2872
Various suggestions to downgrade sprockets to fix a segfault crash: sass/sassc-ruby#207 sass/sassc-rails#122 rails/sprockets#633 We'll see if that fixes it for us. Refs: #2872
Just adding another comment saying that disabling the concurrent mode fixes the issue for me. Basically, I did this: Sprockets.export_concurrent = false if Rails.env.test? So I can run the tests in my CI job. |
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. |
For us the problem could be identified as iterating through a non thread-safe array in the manifest.json.erb file that is part of our asset pipeline, so maybe that helps some of you. We solved it by wrapping the array in |
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` project and might mitigate it until we adjust the asset build system. sass/sassc-ruby#207
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` project and might mitigate it until we adjust the asset build system. Fixes #2130 sass/sassc-ruby#207
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. |
Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per rails/sprockets#633 and sass/sassc-ruby#207, switching concurrent asset generation seems to resolve the problem. The unproven theory is that this reflects that Sprockets 4 uses threads which causes problems for sassc. A consequence of this is that asset pre-compilation may be slower than it could be.
Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per rails/sprockets#633 and sass/sassc-ruby#207, switching concurrent asset generation seems to resolve the problem. The unproven theory is that this reflects that Sprockets 4 uses threads which causes problems for sassc. A consequence of this is that asset pre-compilation may be slower than it could be.
Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per rails/sprockets#633 and sass/sassc-ruby#207, switching concurrent asset generation seems to resolve the problem. The unproven theory is that this reflects that Sprockets 4 uses threads which causes problems for sassc. A consequence of this is that asset pre-compilation may be slower than it could be.
Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per rails/sprockets#633 and sass/sassc-ruby#207, switching concurrent asset generation seems to resolve the problem. The unproven theory is that this reflects that Sprockets 4 uses threads which causes problems for sassc. A consequence of this is that asset pre-compilation may be slower than it could be.
Using Sassc and Sprockets seems somewhat prone to segmentation faults which seems to be a common issue with Sprockets 4. As per rails/sprockets#633 and sass/sassc-ruby#207, switching concurrent asset generation seems to resolve the problem. The unproven theory is that this reflects that Sprockets 4 uses threads which causes problems for sassc. A consequence of this is that asset pre-compilation may be slower than it could be.
@jussihirvi thank you! That helped me as well. I am tremendously grateful for your solution. |
I got this on sassc-2.4.0 and ruby-2.7.0 |
I just got the same issue with ruby 3.2 and rails 7.0.1 (Old macOS 13.10 - not sure if that's important). I can confirm that adding |
I think we can close this issue because this is an issue with Sprockets, not with 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 rails/sprockets#759. Those of you having trouble might want to upgrade to v4.2.1. I'm not sure if In GitLab, we use Sidekiq to run background jobs to send notification e-mails. I can easily reproduce a seg fault by:
20.times { NewIssueWorker.perform_async(1, 1) } I believe this was happening:
The following contains the Ruby and C backtrace: /home/gdk/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/lib/sassc/engine.rb:43: [BUG] Segmentation fault at 0x0000000000000000 ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux] |
Hey, I encounter another segmentation fault using latest gems and ruby 3.3.0. When try to precompile the assets of a rails app inside a docker container (ruby-3.3.0:alpine) I receive the following error:
I have tried to set the |
As @stanhu suggested, I upgraded Sprockets gem to v4.2.1 and got it fix for me. My setup:
|
Sometimes, when I make some changes to my
.scss
files in my Rails 6 app, I get the following when runningrails 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 gettingI 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.
The text was updated successfully, but these errors were encountered: