We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Xdebug: empty reply from server / segmentation fault (issue with Volt anonymous functions)

I'm trying to get started with Xdebug (2.2.4/2.2.5) but my Phalcon app seems to refuse working properly with it. I get an empty reply from the server (using Curl: curl: (52) Empty reply from server)

( -- edit: Apache logs notice child pid xxxx exit signal Segmentation fault (11) in error log )

It do get content / a response when I request a file directly (not handled by Phalcon), or when I request an URL that doesn't exist (non-existing controller - I do get a Phalcon exception then, which I also can catch with dispatch:beforeException, and then e.g. forward the dispatcher to an error controller / 404 page.)

For what it's worth; I'm running CentOS 6.5 as a VirtualBox guest. Apache 2.2/mod_php5. Tested with Phalcon 1.2.6(-safe) and 1.3.1

Does anyone have a clue? Thanks!



8.1k
Accepted
answer
edited May '14

Ok, found it - the problem seems to be triggerd when calling a custom Volt function (from a view) that's registered as an anonymous function. In that case Phalcon won't even compile the view tpl.

Of course the question now is if Phalcon is doing something 'funky', or it is simply a bug in Xdebug?

Edit: it seems this has already been reported: https://github.com/phalcon/cphalcon/issues/2269

Yeah, it's not working with anonymous functions. Meanwhile everyone with this issue can implement custom methods and refer to them by string just like you do for adding native PHP functions to Volt.

<?php
namespace Services;

use Phalcon\Mvc\View\Engine\Volt as PhVolt;

class Volt extends PhVolt
{ 
    function __construct($view, $dependencyInjector = NULL)
    {
        parent::__construct($view, $dependencyInjector);

        $this->setOptions([
            'compileAlways'     => true,
            'compiledPath'      => VOLT_COMPILE_DIR,
            'compiledSeparator' => '--'
            ]);

        $this->getCompiler()->addFunction('public_dump', 'Services\Volt::publicDump');
    }

    public static function publicDump($object)
    {
        return print_r(get_object_vars($object), true);
    }
    ...


8.1k

Thanks for your feedback! Yes, I could do that. (And then hoping for some smooth sailing from then on of course... ;-))

Do you have any idea if this is a bug in Xdebug somehow, or is it Phalcon related?

I believe it isn't XDebug related, since I've experienced this issue before starting to work with XDebug.



8.1k
edited Jun '14

I ran into other issues with Xdebug enabled, I believe having to do with the Paginator.

It just seems Phalcon with Xdebug is somewhat of a no-go?