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

500 error on fresh install (PHP Warning: preg_match_all(): Allocation of JIT memory failed) #5094

Closed
chocolata opened this issue May 27, 2020 · 11 comments

Comments

@chocolata
Copy link

Hi,

I recently moved a site to a shared server that has roughly the same configuration as my previous server did. The problem is that every so often, an error 500 appears, intermittently and without a clear cause. As a test, I tried to do a clean install, but the errors seem to persist.

This is the stack trace:

2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: PHP Fatal error: Uncaught ReflectionException: Class view does not exist in /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php:752, referer: https://www.mysite.eu/contact				Apache error
2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: Stack trace:, referer: https://www.mysite.eu/contact				Apache error
2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #0 /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(752): ReflectionClass->__construct('view'), referer: https://www.mysite.eu/contact				Apache error
2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #1 /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\\Container\\Container->build('view'), referer: https://www.mysite.eu/contact				Apache error
2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #2 /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(586): Illuminate\\Container\\Container->resolve('view', Array), referer: https://www.mysite.eu/contact				Apache error
2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #3 /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(732): Illuminate\\Container\\Container->make('view', Array), referer: https://www.mysite.eu/contact				Apache error
2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #4 /var/www/vhosts/mysite.eu/httpdocs/vendor/october/rain/src/Foundation/Application.php(162): Illuminate\\Foundation\\Application->make('view'), referer: https://www.mysite.eu/contact				Apache error
2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #5 /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/ in /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 752, referer: https://www.mysite.eu/contact				Apache error
2020-05-27 14:32:14	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: PHP Fatal error: Uncaught ReflectionException: Class view does not exist in /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php:752, referer: https://www.mysite.eu/contact				Apache error

When I Google these errors, it states that I should run the command composer dump-autoload in the project root, but of course there is no composer file in the root.

Also, I think it's so strange that the problem is intermittent and happens in random pages and that it happens also with a clean install. Do you guys have a clue what might be wrong here?

Thanks in advance for helping me out.

@LukeTowers
Copy link
Contributor

Try deleting the vendor directory and adding the composer.json file from the repo and then running composer update.

@chocolata
Copy link
Author

Hi Luke,

Just did that and then it throws the following error:

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires wikimedia/composer-merge-plugin 1.4.1 -> satisfiable by wikimedia/composer-merge-plugin[v1.4.1].
    - wikimedia/composer-merge-plugin v1.4.1 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.

You are using a snapshot build of Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report an issue to them to ask them to support Composer 2. To work around this you can run Composer with --ignore-platform-reqs, but this will also ignore your PHP version and may result in bigger problems down the line.

What do you make of that?

@LukeTowers
Copy link
Contributor

See wikimedia/composer-merge-plugin#184. If you can, downgrade to Composer 1.x, if not then just remove that part of the composer.json file (note that this means that running composer update from your project root to pull in your plugin dependencies will not work)

@chocolata
Copy link
Author

chocolata commented May 27, 2020

Thanks Luke... When I remove the vendor folder now and run composer update using the modified composer.json file, I get several errors:

 ...
  - Installing symfony/yaml (v3.4.40): Extracting archive
  - Installing october/rain (v1.0.465): Extracting archive
  - Installing october/backend (v1.0.465): Extracting archive
    Install of october/backend failed
  - Installing october/cms (v1.0.465): Extracting archive
    Install of october/cms failed
  - Installing october/system (v1.0.465): Extracting archive
    Install of october/system failed
  - Installing php-parallel-lint/php-parallel-lint (v1.2.0): Extracting archive
  - Installing phpunit/phpunit-selenium (1.3.3): Extracting archive
  - Installing squizlabs/php_codesniffer (3.5.5): Extracting archive
                                                                                     
  [RuntimeException]                                                                                   
  Expected empty path to extract october/backend-1.0.465.0 into but directory exists: modules/backend 

After this, the site doesn't load at all anymore (always 500 errors).
Thanks for looking into this.

@LukeTowers
Copy link
Contributor

Remove vendor folder & the modules folder and then run it again.

@chocolata
Copy link
Author

chocolata commented May 27, 2020

Thank you, Luke. Now it fails with the following message:

  ...
  - Installing php-parallel-lint/php-parallel-lint (v1.2.0): Extracting archive
  - Installing phpunit/phpunit-selenium (1.3.3): Extracting archive
  - Installing squizlabs/php_codesniffer (3.5.5): Extracting archive

68 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package leafo/scssphp is abandoned, you should avoid using it. Use scssphp/scssphp instead.
Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files

                                                                                                                                      
  [RuntimeException]                                                                                                                  
  Could not scan for classes inside "tests/concerns/InteractsWithAuthentication.php" which does not appear to be a file nor a folder  
                                                                           

Also, now the site is again dead...

@LukeTowers
Copy link
Contributor

@maartenmachiels remove the parts of composer.json referencing the tests directory.

@chocolata
Copy link
Author

Thank you Luke. This is what the terminal outputs after doing this:

  - Installing phpunit/phpunit-selenium (1.3.3): Extracting archive
  - Installing squizlabs/php_codesniffer (3.5.5): Extracting archive

Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package leafo/scssphp is abandoned, you should avoid using it. Use scssphp/scssphp instead.
Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.

Generating autoload files
Composer detected issues in your platform:

Your Composer dependencies require a PHP version ">= 7.0.8" and "< 8.0.0". You are running 5.4.16.-bash-4.2$

The site itself is running on PHP 7.3.18, but it seems the PHP version of the terminal is on PHP 5.4. As this is a shared environment, I don't really have control over it.

The site is back up again now, but the intermittent issues persist. This is what is present in the logs after the composer update command:

2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: PHP Fatal error: Uncaught Error: Class 'Event' not found in /var/www/vhosts/mysite.eu/httpdocs/vendor/october/rain/src/Foundation/Exception/Handler.php:57, referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: Stack trace:, referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #0 /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(81): October\\Rain\\Foundation\\Exception\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError)), referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #1 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleException(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError)), referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #2 {main}, referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: thrown in /var/www/vhosts/mysite.eu/httpdocs/vendor/october/rain/src/Foundation/Exception/Handler.php on line 57, referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: PHP Fatal error: Uncaught Error: Class 'Event' not found in /var/www/vhosts/mysite.eu/httpdocs/vendor/october/rain/src/Foundation/Exception/Handler.php:57, referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: Stack trace:, referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #0 /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(81): October\\Rain\\Foundation\\Exception\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException)), referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #1 /var/www/vhosts/mysite.eu/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(123): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleException(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException)), referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #2 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleShutdown(), referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: #3 {main}, referer: https://www.mysite.eu/historiek-concept				Apache error
2020-05-27 20:08:29	Warning	XX.XXX.XX.XXX		mod_fcgid: stderr: thrown in /var/www/vhosts/mysite.eu/httpdocs/vendor/october/rain/src/Foundation/Exception/Handler.php on line 57, referer: https://www.mysite.eu/historiek-concept				Apache error

Upon investigating the logs, I do see another error message. It is far less frequent, but it is there:

mod_fcgid: stderr: PHP Warning: preg_match_all(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in /var/www/vhosts/mysite.eu/httpdocs/vendor/symfony/http-foundation/HeaderBag.php on line 324

It sucks but I cannot set any specific PHP settings as this is a shared hosting environment. I can ask the provider to set that for me though, but that would be tomorrow. What do you think?

@LukeTowers
Copy link
Contributor

@maartenmachiels honestly, I would move to a different host. Otherwise your best bet would be to find the PHP 7.3 executable on the server and run composer through that so that it downloads the right version of the dependencies for your server.

@chocolata
Copy link
Author

Thanks for your advice Luke, I will contact the provider tomorrow and see if we can get that done... I will post my findings here as soon as I can.

@chocolata
Copy link
Author

Update: problem solved!

I just got off the phone with the provider. They set pcre.jit=0 as an additional directive in the PHP settings (a field to which I did not have access, as this particular hosting is a shared hosting environment).

Even without running any further composer commands, the site now works without error. It seems that this one error triggered the other errors regarding unfound dependencies. I hope this can help others who might encounter the same issue.

Thanks for your support, Luke!

@chocolata chocolata changed the title 500 error on fresh install 500 error on fresh install (PHP Warning: preg_match_all(): Allocation of JIT memory failed) May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants