cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Apache crash when getSingleResult is called

Open MickaelViaud opened this issue 12 years ago • 19 comments

When using QueryBuilder and getSingleResult, Apache crash (segmentation fault). I don't have any problem if i use execute() instead of getSingleResult.

AH00428: Parent: child process 17292 exited with status 255 -- Restarting.
 [notice] child pid 718 exit signal Segmentation fault (11)
$this->currentOffer = $this->modelsManager->createBuilder()
    ->from('Model1')
    ->getQuery()
    ->getSingleResult();

Tested with error on Windows 7 :

  • Apache 2.4.4
  • PHP 5.4.12
  • Phalcon 1.3.1

And on MacOSX :

  • Apache to 2.2.26
  • PHP 5.5.10
  • Phalcon 1.3.1

MickaelViaud avatar May 13 '14 12:05 MickaelViaud

Can you please test in Phalcon 1.3.2 again?

dreamsxin avatar May 14 '14 02:05 dreamsxin

How can I get the Phalcon 1.3.2 DLL ? I don't see any link to the compiled DLL.

MickaelViaud avatar May 14 '14 08:05 MickaelViaud

Now, Haven't 1.3.2 DLL files. Can you compile the installation on the MacOSX?

dreamsxin avatar May 14 '14 08:05 dreamsxin

I'll try it today ;) Thanks.

MickaelViaud avatar May 14 '14 08:05 MickaelViaud

Still have the problem with phalcon 1.3.2 on MacOSX.

  • Apache 2.2.26
  • PHP 5.5.10

MickaelViaud avatar May 14 '14 10:05 MickaelViaud

I separate test this code is correct.

  • Apache/2.4.6
  • PHP 5.5.7 Do you install it from ext dir? Like this:
cd ext
phpize
./configure
make
make install

You can call phpinfo(), see phalcon version number .

dreamsxin avatar May 15 '14 00:05 dreamsxin

HI,

Nop i follow this tutorial for MAMP http://www.extreme-creations.co.uk/blog/2014/03/how-to-install-phalcon-php-framework-with-mamp-on-osx/

Are these any difference between this way and your way ?

MickaelViaud avatar May 19 '14 08:05 MickaelViaud

Hi,

The problem is still here in Phalcon 1.3.2 ...

MickaelViaud avatar Jul 02 '14 12:07 MickaelViaud

Fixed in 1.3.3

ghost avatar Sep 05 '14 11:09 ghost

Hi, Is there a plan for new DLL's in the near future?

Our app has this problem for all single (non-cli) requests - even via Model::findFirst().

VampireTiger avatar Sep 12 '14 13:09 VampireTiger

Still getting the Apache restart error when accessing database - same as above.

I have a route that leads to a controller that has a couple of grouped Get Actions - added in a class extending the Router\Group via the addGet() method.

One of the actions has a call to Client::find('id='.$key); which works perfectly.

Another action (a few lines away in the code) has only one line: a copy of the Client::find() line. This one causes an apache restart. The Action has no other code in it - just a single line.

If the line is commented out then there is no apache restart. Very confusing!

Monitoring the $key value shows that it is the same with each call, there are no other variations that are obvious within the PHP code.

This is just one example of the restart happening - it happens on nearly all controllers.

Running on a Windows 8.1 computer with Wampserver - Apache 2.4.9, PHP 5.5.12, MySQL 5.6.17 and Phalcon 1.3.3

This restart is consistent across multiple computers and browsers.

Has anyone tested their code from above with 1.3.3 to see if it works properly for them?

When controllers are using more basic routes (non-grouped) it all seems to be ok. Phalcon runs very well in most cases - just this aspect is causing a problem.

VampireTiger avatar Sep 24 '14 09:09 VampireTiger

Hi there,

I have the same issue in Phalcon 2.0.0

Here the errors

[Wed Apr 22 10:06:05.557768 2015] [mpm_winnt:notice] [pid 10956:tid 468] AH00428: Parent: child process 12160 exited with status 255 -- Restarting.
[Wed Apr 22 10:06:05.827784 2015] [mpm_winnt:notice] [pid 10956:tid 468] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations
[Wed Apr 22 10:06:05.827784 2015] [mpm_winnt:notice] [pid 10956:tid 468] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13
[Wed Apr 22 10:06:05.827784 2015] [core:notice] [pid 10956:tid 468] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.9'
[Wed Apr 22 10:06:05.828784 2015] [mpm_winnt:notice] [pid 10956:tid 468] AH00418: Parent: Created child process 224
[Wed Apr 22 10:06:06.440819 2015] [mpm_winnt:notice] [pid 224:tid 396] AH00354: Child: Starting 64 worker threads.
[Wed Apr 22 10:06:28.908104 2015] [mpm_winnt:notice] [pid 10956:tid 468] AH00428: Parent: child process 224 exited with status 255 -- Restarting.
[Wed Apr 22 10:06:29.099115 2015] [mpm_winnt:notice] [pid 10956:tid 468] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations
[Wed Apr 22 10:06:29.099115 2015] [mpm_winnt:notice] [pid 10956:tid 468] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13
[Wed Apr 22 10:06:29.099115 2015] [core:notice] [pid 10956:tid 468] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.9'
[Wed Apr 22 10:06:29.102115 2015] [mpm_winnt:notice] [pid 10956:tid 468] AH00418: Parent: Created child process 13248
[Wed Apr 22 10:06:30.085171 2015] [mpm_winnt:notice] [pid 13248:tid 396] AH00354: Child: Starting 64 worker threads.

Please advise.

Thank You.

nasrulhazim avatar Apr 22 '15 02:04 nasrulhazim

@nasrulhazim Could you please post the code that shows up the problem?

andresgutierrez avatar Apr 22 '15 02:04 andresgutierrez

This is the main page controller.

I have several other modules, with following route set in route.php. Previously on Phalcon 1.3.4 it's working fine but when migrated to Phalcon 2.0.0, this issue come up.

<?php

use Phalcon\Mvc\Router;

$di->set('router', function () use ($modules, $defaultModule)  {

    $router = new Router(false);

    /**
     * Remove Extra Slashes
     * http://docs.phalconphp.com/en/latest/reference/routing.html#dealing-with-extra-trailing-slashes
     */
    $router->removeExtraSlashes(true);

    /**
     * Setting Default Paths
     * http://docs.phalconphp.com/en/latest/reference/routing.html#setting-default-paths
     */
    if(!empty($defaultModule)) {
        $router->setDefaultModule($defaultModule);
    }

    /**
     * Set Default Route
     * http://docs.phalconphp.com/en/latest/reference/routing.html#setting-the-default-route
     */
    $router->add('/', array(
        'namespace' => 'App\Controller',
        'controller' => 'Index',
        'action' => 'index'
    ));

    /**
     * Set Not Found Page
     * http://docs.phalconphp.com/en/latest/reference/routing.html#not-found-paths
     * See [app.config.dispatcher.php]
     */
    // $router->notFound(array(
    //     'controller' => 'error',
    //     'action' => 'e404'
    // ));

    /**
     * Set Default Route to Module Manager
     * http://docs.phalconphp.com/en/latest/reference/routing.html#routing-to-modules
     */
    $router->add('/modman', array(
        'namespace' => 'Mod\ModMan\Controllers',
        'module' => 'modman',
        'controller' => 'Index',
        'action' => 'index'
    ));

    /**
     * Set Route to Module Manager Actions
     * http://docs.phalconphp.com/en/latest/reference/routing.html#routing-to-modules
     */
    $router->add('/modman/:action', array(
        'namespace' => 'Mod\ModMan\Controllers',
        'module' => 'modman',
        'controller' => 'Index',
        'action' => 1
    ));

    /**
     * Generic Modules Route
     * http://docs.phalconphp.com/en/latest/reference/routing.html#routing-to-modules
     */
    $router->add('/:module/:controller/:action/:params', array(
        'module' => 1,
        'controller' => 2,
        'action' => 3,
        'params' => 4
    ));

    return $router;
});

This is the default page controller

<?php
namespace App\Controller;

class IndexController extends ControllerBase
{
    public function indexAction()
    {
        $this->view->setVar('title','phalcon-multi-module-skeleton: App Controller');
        $this->assets->addCss('css/_Index_index.css');
        $this->assets->addJs('js/_Index_index.js'); // module_controller_action.js
    }
}

nasrulhazim avatar Apr 22 '15 02:04 nasrulhazim

@nasrulhazim Could you please post a small script ready-to-run that reproduces the problem?

andresgutierrez avatar Apr 22 '15 02:04 andresgutierrez

Give me a minute, I will try to create one. Currently running on multiple-modules app.

nasrulhazim avatar Apr 22 '15 02:04 nasrulhazim

Here one thing I noticed, adding namespace key in adding new route causing the error. But when i remove the namespace key, the error message I get is PhalconException: IndexController handler class cannot be loaded. Here the default route, just comment out the namespace key will produce the above error I mentioned.

$router->add('/', array(
        'namespace' => 'App\Controller',
        'controller' => 'Index',
        'action' => 'index'
    ));

nasrulhazim avatar Apr 22 '15 03:04 nasrulhazim

I have a simple phalcon app structure now with phalcon2/public/index.php as following:

<?php
use Phalcon\Mvc\Router;
try {

    //Register an autoloader
    $loader = new \Phalcon\Loader();

    $loader->registerNamespaces(
        array(
            'App\Controller' => '../app/controllers/',
            'App\Model' => '../app/models/',
        )
    )->register();

    //Create a DI
    $di = new Phalcon\DI\FactoryDefault();

    $di->set('router', function (){

        $router = new Router(false);

        $router->removeExtraSlashes(true);

        $router->add('/', array(
            // 'namespace' => 'App\Controller',
            'controller' => 'Index',
            'action' => 'index'
        ));

        return $router;
    });

    //Setup the database service
    $di->set('db', function(){
        return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
            "host" => "localhost",
            "username" => "root",
            "password" => "",
            "dbname" => "phalcon2"
        ));
    });

    //Setup the view component
    $di->set('view', function(){
        $view = new \Phalcon\Mvc\View();
        $view->setViewsDir('../app/views/');
        return $view;
    });

    //Setup a base URI so that all generated URIs include the "tutorial" folder
    $di->set('url', function(){
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/phalcon2/');
        return $url;
    });

    //Handle the request
    $application = new \Phalcon\Mvc\Application($di);

    echo $application->handle()->getContent();

} catch(\Phalcon\Exception $e) {
     echo "PhalconException: ", $e->getMessage();
}

And my phalcon2/app/controllers/IndexController.php as following:

<?php
 namespace App\Controller;

class IndexController extends \Phalcon\Mvc\Controller
{

    public function indexAction()
    {

    }

}

If i'm using $loader->registerDirs(), and remove the namespace in IndexController.php, the app working fine.

nasrulhazim avatar Apr 22 '15 03:04 nasrulhazim

instead of getSingleResult()

->execute() ->getFirst();

is working.

I know 1.3.2 is an old version but I do not want to upgrade the server now. Do you think I am missing anything with that solution ?

anilyeni avatar Jul 28 '15 19:07 anilyeni