Skip to content
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

Drush commands within webroot loop infinitely running out of memory #2755

Closed
mradcliffe opened this issue May 13, 2017 · 13 comments
Closed

Drush commands within webroot loop infinitely running out of memory #2755

mradcliffe opened this issue May 13, 2017 · 13 comments

Comments

@mradcliffe
Copy link

I am setting up my Drupal 8 vm for 8.4.x core and contrib development and am trying to update and use drush 9 as it is required for Drupal 8.4.x.

  • I completely removed drush:
    • composer global remove drush/drush
    • rm -rf ~/.drush
  • I installed drush 9.0.0-beta1 after having first added minimum-stability to dev as it's needed.
    • composer global require drush/drush:^9.0.0-beta1 installed dev-master f46fe29, which is the latest commit on master as of 2017.05.13.
  • Running drush status in my home directory prints out basic PHP information.
  • Running drush status in a Drupal 8.4.x webroot (e67f64e from a week ago) causes drush to loop infinitely trying to fork processes

The following line is repeated until OOM error occurs:

[info] Begin redispatch via drush_invoke_process(). Calling proc_open(env COLUMNS=91
$HOME/.composer/vendor/drush/drush/drush --root=/var/www/drupal8.dev/webroot --verbose  core-status 2>&1);

If I remove drush and use composer require drush/drush:dev-master#990a4b321a1b299c63a1e1eb7b26fdaf0e8c4a50 then the error no longer occurs. So I think this is something to do with PR #2749 which introduced webflo/drupal-finder. I am not sure why it would have issues with the directory that I have checked out as I am using a standard git clone of drupal 8.4.x with a healthy amount of contrib. modules in modules/ that are there for porting/development work. webroot contains the following:

autoload.php
composer.json
composer.lock
core
example.gitignore
index.php
libraries
modules
profiles
README.txt
robots.txt
sites
themes
update.php
vendor
web.config

OOM error:

 [warning] exec(): Unable to fork [tput colors 2>&1] preflight.inc:615
 [warning] exec(): Unable to fork [tput colors 2>&1] preflight.inc:615
 [warning] exec(): Unable to fork [tput colors 2>&1] preflight.inc:615

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 20480
bytes) in
$HOME/.composer/vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock.php
on line 113
PHP Stack trace:
PHP   1. {main}() $HOME/.composer/vendor/drush/drush/drush:0
PHP   2. require() $HOME/.composer/vendor/drush/drush/drush:4
PHP   3. drush_main()
$HOME/.composer/vendor/drush/drush/drush.php:10
PHP   4. drush_preflight_command_dispatch()
$HOME/.composer/vendor/drush/drush/includes/preflight.inc:76
PHP   5. drush_parse_command()
$HOME/.composer/vendor/drush/drush/includes/preflight.inc:803
PHP   6. drush_get_commands()
$HOME/.composer/vendor/drush/drush/includes/command.inc:1287
PHP   7. annotationcommand_adapter_commands()
$HOME/.composer/vendor/drush/drush/includes/command.inc:1043
PHP   8. annotationcommand_adapter_get_commands()
$HOME/.composer/vendor/drush/drush/includes/annotationcommand_adapter.inc:88
PHP   9. annotationcommand_adapter_create_commandfile_instance()
$HOME/.composer/vendor/drush/drush/includes/annotationcommand_adapter.inc:274
PHP  10. Robo\Runner->registerCommandClass()
$HOME/.composer/vendor/drush/drush/includes/annotationcommand_adapter.inc:296
PHP  11.
Consolidation\AnnotatedCommand\AnnotatedCommandFactory->createCommandsFromClass()
$HOME/.composer/vendor/consolidation/robo/src/Runner.php:202
PHP  12.
Consolidation\AnnotatedCommand\AnnotatedCommandFactory->registerCommandHooksFromClassInfo()
$HOME/.composer/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:149
PHP  13.
Consolidation\AnnotatedCommand\AnnotatedCommandFactory::isHookMethod()
$HOME/.composer/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:335
PHP  14. Consolidation\AnnotatedCommand\Parser\CommandInfo->hasAnnotation()
$HOME/.composer/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:310
PHP  15. Consolidation\AnnotatedCommand\Parser\CommandInfo->parseDocBlock()
$HOME/.composer/vendor/consolidation/annotated-command/src/Parser/CommandInfo.php:299
PHP  16.
Consolidation\AnnotatedCommand\Parser\Internal\CommandDocBlockParserFactory::parse()
$HOME/.composer/vendor/consolidation/annotated-command/src/Parser/CommandInfo.php:684
PHP  17.
Consolidation\AnnotatedCommand\Parser\Internal\CommandDocBlockParser2->parse()
$HOME/.composer/vendor/consolidation/annotated-command/src/Parser/Internal/CommandDocBlockParserFactory.php:13
PHP  18. phpDocumentor\Reflection\DocBlock->__construct()
$HOME/.composer/vendor/consolidation/annotated-command/src/Parser/Internal/CommandDocBlockParser2.php:24
PHP  19. phpDocumentor\Reflection\DocBlock->cleanInput()
$HOME/.composer/vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock.php:88
PHP  20. preg_replace()
$HOME/.composer/vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock.php:113

Fatal error: Out of memory (allocated 8388608) (tried to allocate 20480 bytes)
in
$HOME/.composer/vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock.php
on line 113

Call Stack:
    0.0001     349176   1. {main}()
$HOME/.composer/vendor/drush/drush/drush:0
    0.0002     350080   2.
require('$HOME/.composer/vendor/drush/drush/drush.php')
$HOME/.composer/vendor/drush/drush/drush:4
    0.0021     539968   3. drush_main()
$HOME/.composer/vendor/drush/drush/drush.php:10
    0.1243    5748184   4. drush_preflight_command_dispatch()
$HOME/.composer/vendor/drush/drush/includes/preflight.inc:76
    0.1244    5748184   5. drush_parse_command()
$HOME/.composer/vendor/drush/drush/includes/preflight.inc:803
    0.1244    5748184   6. drush_get_commands()
$HOME/.composer/vendor/drush/drush/includes/command.inc:1287
    0.1244    5748208   7. annotationcommand_adapter_commands()
$HOME/.composer/vendor/drush/drush/includes/command.inc:1043
    0.1245    5748272   8. annotationcommand_adapter_get_commands()
$HOME/.composer/vendor/drush/drush/includes/annotationcommand_adapter.inc:88
    0.2550    8108400   9.
annotationcommand_adapter_create_commandfile_instance()
$HOME/.composer/vendor/drush/drush/includes/annotationcommand_adapter.inc:274
    0.2564    8144376  10. Robo\Runner->registerCommandClass()
$HOME/.composer/vendor/drush/drush/includes/annotationcommand_adapter.inc:296
    0.2565    8144696  11.
Consolidation\AnnotatedCommand\AnnotatedCommandFactory->createCommandsFromClass()
$HOME/.composer/vendor/consolidation/robo/src/Runner.php:202
    0.2572    8161888  12.
Consolidation\AnnotatedCommand\AnnotatedCommandFactory->registerCommandHooksFromClassInfo()
$HOME/.composer/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:149
    0.2578    8170904  13.
Consolidation\AnnotatedCommand\AnnotatedCommandFactory::isHookMethod()
$HOME/.composer/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:335
    0.2578    8170904  14.
Consolidation\AnnotatedCommand\Parser\CommandInfo->hasAnnotation()
$HOME/.composer/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:310
    0.2578    8170904  15.
Consolidation\AnnotatedCommand\Parser\CommandInfo->parseDocBlock()
$HOME/.composer/vendor/consolidation/annotated-command/src/Parser/CommandInfo.php:299
    0.2578    8170904  16.
Consolidation\AnnotatedCommand\Parser\Internal\CommandDocBlockParserFactory::parse()
$HOME/.composer/vendor/consolidation/annotated-command/src/Parser/CommandInfo.php:684
    0.2578    8171016  17.
Consolidation\AnnotatedCommand\Parser\Internal\CommandDocBlockParser2->parse()
$HOME/.composer/vendor/consolidation/annotated-command/src/Parser/Internal/CommandDocBlockParserFactory.php:13
    0.2578    8171176  18. phpDocumentor\Reflection\DocBlock->__construct()
$HOME/.composer/vendor/consolidation/annotated-command/src/Parser/Internal/CommandDocBlockParser2.php:24
    0.2578    8171176  19. phpDocumentor\Reflection\DocBlock->cleanInput()
$HOME/.composer/vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock.php:88
    0.2578    8171176  20. preg_replace()
$HOME/.composer/vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock.php:113

 [error]  Drush command terminated abnormally due to an unrecoverable error.
Error: Out of memory (allocated 8388608) (tried to allocate 20480 bytes) in
$HOME/.composer/vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock.php,
line 113
 [info] A non well formed numeric value encountered drush.inc:1444
 [info] End redispatch via drush_invoke_process().
@mradcliffe
Copy link
Author

drush status in home directory for PHP 7.1.0 info:

 PHP binary    : /usr/bin/php
 PHP config    : /etc/php.ini
 PHP OS        : Linux
 Drush script  : $HOME/.composer/vendor/drush/drush/drush.php
 Drush version : 9.0-dev-95ff5f7
 Drush temp    : /tmp
 Drush configs :
 Drush aliases :

@mradcliffe
Copy link
Author

Does this comment apply here because I installed with composer global require drush/drush?

Global install of Drush is no longer supported because you get errors exactly like the one described here. The install docs already don't mention it anymore. Each project needs to name Drush as a dependency. Its fine if Drush8 sites stick with the global install and Drupal 8.3-. For Drupal 8.4, they are going to need to use Drush9 as a dependency.

@weitzman
Copy link
Member

Yes it does.

@mradcliffe
Copy link
Author

Thank you for the reply, @weitzman. And I see the note in the master branch version of the documentation now. I think that is prominent enough on the documentation sub-site.

I think I'll need to live without drush for core development work flow for now.

@kmajzlik
Copy link

I am just playing with same problem. I have drush launcher of any version(i tried current 0.5.0 too). I have composer based D8 project, drupal is in "docroot" directory. I have there Drush 9.0.0-rc1.
When i just run drush status i have some loop or something, just getting "Killed!" messages to terminal.
However i have almost same dockerized environment and all goes ok. I have been comparing extensions and things like that and found it:
sudo -u www-data drush status
and it is working.

So what can cause the problem? Running php7.0-fpm.

@kmajzlik
Copy link

So my temporary solution...

  1. drush launcher phar located as /usr/local/bin/drush-launcher
  2. edited ~/.bashrc , added this line to end of file:
    alias drush="sudo -u www-data drush-launcher"

Not the best, i have to type password sometimes but it simply works.

Another note: Drupal console + launcher works well without any hacking.

This seems to me like regular issue but i am not able to re-open it.

@awm086
Copy link

awm086 commented Feb 1, 2018

I am having the same issue.

./../vendor/drush/drush/drush status
mmap() failed: [12] Cannot allocate memory
Can't initialize heap: [12] Cannot allocate memory

Noticed that if you have your Drupal installation or parent directory somehow symlinked then this error can occur:


lrwxrwxrwx 1 vagrant vagrant 8 Feb  1 20:15 sites -> /var/www
vagrant@vdd:~$ cd sites/d8/web/
vagrant@vdd:~/sites/d8/web$ ../vendor/bin/drush st
^C

I am assuming drush_locate_root does not work with symlinks.

@kmajzlik
Copy link

kmajzlik commented Feb 1, 2018

Yeah that is the reason for me too. When i am at /var/www/site it works. When i am at ~/www/site (symlink to /var/www/) it fails.
@weitzman - can you please rename and re-open? Seems like regular issue with specified problem now.

@awm086
Copy link

awm086 commented Feb 2, 2018

I think this could potentially be a bug with drupal-finder.

@kmajzlik
Copy link

kmajzlik commented Feb 2, 2018

But Drupal Console uses it too and works without this bug.

@kmajzlik
Copy link

kmajzlik commented Feb 2, 2018

I do not use composer.json in drupal root. I use composer install paths (docroot/core for drupal/core package). I have drupal in subdirectory(docroot) like Lightning and many others have.

@awm086
Copy link

awm086 commented Feb 2, 2018

yup I am still not sure ... what's going on. I thought it was related but I don't think it's relevant.

@awm086
Copy link

awm086 commented Feb 2, 2018

I think I found the issue and opened a PR. #3342
@weitzman pls let us know if we need to re-opend this issue or open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants