CHH / heroku-buildpack-php

A more advanced PHP buildpack for Heroku, inspired by the Node.js buildpack
MIT License
265 stars 156 forks source link

Segmentation fault during autoload #84

Closed digifish closed 10 years ago

digifish commented 10 years ago

I keep bumping into a "segmentation fault" error or "zend_mm_heap corrupted" message right after composer finishes getting packages and says "Generating optimized autoload files."

I've tried several PHP versions, and tried to tweak the settings.

My current composer.json block:

"extra": {
        "heroku": {
            "document-root": "web",
            "index-document": "app.php",
            "framework": "symfony2",
            "engines": {
                "php": "5.5.8",
                "nginx": "1.3.14"
            },
            "php-config": [
                "date.timezone=UTC",
                "output_buffering=0",   #or 1
                "memory_limit=256M",  #tried to see if this helps
                "xdebug.auto_trace=ON"
            ]
        }
    },
CHH commented 10 years ago

@digifish could you please post your complete composer.json?

digifish commented 10 years ago

Sure. I had made a few tweaks last night, so I just reran this to make sure things were still breaking -- and they are.

{
    "extra": {
        "heroku": {
            "document-root": "web",
            "index-document": "app.php",
            "framework": "symfony2",
            "engines": {
                "php": "5.5.8",
                "nginx": "1.3.14"
            },
            "php-config": [
                "date.timezone=UTC",
                "output_buffering=0",
                "memory_limit=256M",
                "xdebug.auto_trace=ON"
            ]
        },
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        }
    },
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": {
            "": "src/"
        }
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "Automattic/Iris",
                "version": "master",
                "source": {
                    "url": "https://github.com/Automattic/Iris.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        },
        {
            "type": "package",
            "package": {
                "name": "prawnsalad/Nexmo-PHP-lib",
                "version": "master",
                "source": {
                    "url": "https://github.com/prawnsalad/Nexmo-PHP-lib.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],
    "require": {
        "php": ">=5.4.3",
        "ext-pdo": "*",
        "ext-pdo_mysql": "*",
        "ext-SimpleXML": "*",
        "lib-curl": "*",
        "lib-libxml": "*",
        "symfony/symfony": "2.4.*",
        "doctrine/orm": "2.4.*",
        "doctrine/doctrine-bundle": "1.2.*",
        "doctrine/migrations": "dev-master",
        "doctrine/doctrine-migrations-bundle": "dev-master",
        "twig/extensions": "1.*",
        "symfony/assetic-bundle": "2.3.0",
        "symfony/framework-bundle": "2.4.*",
        "symfony/swiftmailer-bundle": "2.3.*",
        "symfony/monolog-bundle": "2.4.*",
        "sensio/distribution-bundle": "2.3.*",
        "sensio/framework-extra-bundle": "2.3.*",
        "sensio/generator-bundle": "2.3.*",
        "friendsofsymfony/user-bundle": "dev-master",
        "knplabs/knp-menu-bundle": "dev-master",
        "knplabs/knp-menu": "dev-master",
        "knplabs/knp-paginator-bundle": "~2.3@dev",
        "knplabs/knp-components": "~1.2@dev",
        "genemu/form-bundle": "2.1.*",
        "egeloen/ckeditor-bundle": "2.*",
        "liip/imagine-bundle": "dev-master",
        "hipaway-etravel/mandrill-bundle": "dev-master",
        "hwi/oauth-bundle": "0.3.*@dev",
        "jms/security-extra-bundle": "dev-master",
        "jms/di-extra-bundle": "dev-master",
        "mopa/bootstrap-bundle": "dev-master",
        "twbs/bootstrap": "dev-master",
        "gedmo/doctrine-extensions": "dev-master",
        "stof/doctrine-extensions-bundle": "~1.1@dev",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "apy/datagrid-bundle": "dev-master",
        "omnipay/authorizenet": "~2.0",
        "omnipay/omnipay": "~2.0",
        "bmatzner/fontawesome-bundle": "~4.0",
        "exercise/htmlpurifier-bundle": "1.0.*@dev",
        "blueimp/jquery-file-upload": "dev-master",
        "civocr/nexmo-php-lib": "dev-master",
        "liip/doctrine-cache-bundle": "dev-master",
        "codeconsortium/ccdn-user-security-bundle": "dev-master"

    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
        ]

    },
    "config": {
        "bin-dir": "bin"
    },
    "minimum-stability": "stable"
}
acedude commented 10 years ago

Got the same problem. Usually goes away after another push or if I modify composer.json:

{
    "name": "uwe/ns2gathers",
    "description": "Natural Selection 2 gathers backend.",
    "authors": [
        {
            "name": "Lukas Nowaczek",
            "email": "lukas@unknownworlds.com"
        }
    ],
    "require": {
        "laravel/framework": "4.1.*",
        "brainboxlabs/brain-socket": "v1.0.0",
        "koraktor/steam-condenser": "1.3.7"
    },
    "require-dev": {
        "way/generators": "dev-master",
        "barryvdh/laravel-ide-helper": "v1.8.0",
        "fzaninotto/faker": "dev-master",
        "phpunit/phpunit": "3.7.27"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php"
        ],
        "psr-0": {
            "Gathers": "app/"
        },
        "files": [
            "vendor/koraktor/steam-condenser/lib/steam-condenser.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan optimize",
            "chmod +x Procfile.sh && ./Procfile.sh"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize",
            "php artisan migrate",
            "chmod +x Procfile.sh && ./Procfile.sh"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable",
    "extra": {
        "heroku": {
            "framework": "silex",
            "document-root": "public",
            "index-document": "index.php"
        }
    }
}
acedude commented 10 years ago

From PHP 5.5.9 changelog:

Fixed bug #66481 (Segfaults on session_name()).

Just saying!

joescoffield commented 10 years ago

For what it's worth, I forked this buildpack and removed the APC extension (+ the 2 nearby), and it still segfaulted. I then removed all of the opcache settings (to let them be their defaults) and haven't seen a single segfault for at least a week. I imagine the issue is the fast shutdown, but I haven't narrowed down which one is the problem because I'm not performance testing yet.

Hope this helps someone.

rayrigam commented 10 years ago

I'm also having a zend_mm_heap corrupted during installation to Heroku. The exception occurs after composer finishes installing public assets for all the bundles, in my case apparently when it tries to run any command in the "heroku/compile" section of the composer.json file (when I remove the "heroku/compile" section, I get no exception). I tried with both PHP 5.5.9 and 5.5.8, and I have the same exception with both (when "compile" commands are defined). I do not think it has to do with my code as I tried it with a fresh Symfony Standard Edition and the HelloBundle and I still get the error. The command inside the "heroku/compile" section does not seem to have effect either, as I tried to do both a php app/console assetic:dump (as shown below) and a simple cp file1 file2, and get the exception in both cases. The conf I used with the fresh Symfony Standard Edition is:

"heroku": {
    "document-root": "web",
    "index-document": "app.php",
    "php-config": [
        "date.timezone=America/New_York",
        "display_errors=off",
        "short_open_tag=off",
        "magic_quotes_gpc=off",
        "register_globals=off",
        "session.auto_start=off"
    ],
    "nginx-includes": ["heroku/nginx_auth.conf"],
    "compile": [
        "php app/console assetic:dump --env=prod --no-debug"
    ]
}
CHH commented 10 years ago

@rayrigam have you tried setting opcache.fast_shutdown=0?

rayrigam commented 10 years ago

@CHH thanks! After setting opcache.fast_shutdown=0 I have not had any 'zend_mm_heap corrupted' exceptions. Do you know why does that lead to an exception? I'm not sure what's that setting for (even though I read the docs), and why do you set it to "1" in the default buildpack configuration? Is there any issue with setting it to "0"? Is it ok to run production with "0"?

CHH commented 10 years ago

I will change it to off by default. The only reason it is this way, is that I've copied a recommended configuration for Opcache from somewhere on the internets.

CHH commented 10 years ago

@rayrigam Changed it to off by default :smiley:

rayrigam commented 10 years ago

@CHH fair enough! thank you! By the way, I'm really glad to have found this buildpack! It looks like it's going to save me lots of time for deployment.

CHH commented 10 years ago

@rayrigam thanks :smile: