I just run into an issue with a D7 site where we wanted to use Grunt. After installing the local Grunt, things started to fail apart and I got PCRE-related segfaults for almost everything (for example drush pm-list). After I found this:

http://drupal.stackexchange.com/questions/126880/how-do-i-prevent-drupal...

I realized that the contents of the node_module folder is causing this. I've modified the package.json file to include the modification in http://drupal.stackexchange.com/a/136951/2216 and now it's working fine.

(Just wanted to tell you guys about this, since I didn't really expect a theme to cause such a huge mess.)

CommentFileSizeAuthor
#6 2514350.patch544 byteskevinquillen

Comments

corbacho’s picture

kevinquillen’s picture

A workaround for now is to update package.json to include rimraf package and add this as a post install script. It will run through and clean up info files in node_modules to avoid segfaulting drupal. I wouldn't wait for core, because this has gone on for some time now.

Example:

{
  "name": "STARTER",
  "version": "8.1.2",
  "devDependencies": {
    // ... other packages ...
    "rimraf": "*"
  },
  "scripts": {
    "postinstall": "node_modules/.bin/rimraf node_modules/**/*.info"
  }
}

rimraf works on Windows/OSX (haven't tried on Linux). Now anytime npm install is ran, that command will clean up the files.

kevinquillen’s picture

Status: Active » Needs work
kevinquillen’s picture

Version: 7.x-5.x-dev » 8.x-5.x-dev

The same fix can be applied for Drupal 8 (I've used extensively in other themes) to prevent segfault. Drupal 8 core has supposedly fixed the behavior, but it still occurred for me. So instead of white screen everyone, we can do this until it is resolved. Not to mention, prior versions of core for 7.x and 8.x will still segfault regardless, so it doesn't hurt to have grunt or gulp execute this.

kevinquillen’s picture

Version: 8.x-5.x-dev » 8.x-6.x-dev

This change can be easily backported.

kevinquillen’s picture

StatusFileSize
new544 bytes

Here is a patch that just ran successfully for me. It deletes all *.info files from the node_modules.

After this, it should not segfault anymore. I have ran into this on various other projects and this kills it dead in its tracks until core can patch it up.

kevinquillen’s picture

Status: Needs work » Needs review
kevinquillen’s picture

Do note that the patch for 8.x-6.x is for Gulp, while lower versions are using Grunt. However, it should work exactly the same, as only package.json is affected - meaning, if this works, we will backport down and test.

kevinquillen’s picture

Dev branches of 7.x-5.x, 8.x-5.x and 8.x-6.x have been updated with this fix. I was able to reproduce on all, and not reproduce after the changes were applied.

rimraf is being added to emulate the rm -rf command, so this will also work on Windows as well.

If you have made modifications to your subtheme Gulpfile/Gruntfile, for instance, changing install directory paths or other customizations, you may need to tweak the post install command to point to your bin directory appropriately.

If your site is segfaulting prior to this, delete node_modules and run npm install again, clear caches and reload.

kevinquillen’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.