I know that eAccelerator can't handle try-catch block correctly at least in my 
experience.
In the other hand, PHPTAL uses its special exception handler if exception is 
finally
passed to outside. They might relate each other on modern PHP, I guess...

How would below(ugly code) work?

// setup $template here

try {
    echo $template->execute();
    $__dummy = 1;  // Avoiding eAccelerator's bug. 
}
catch(Exception $e) {
    $exception = $e;
}
if(isset($exception)) {
    // echo and exit or...
    $handler = new PHPTAL_ExceptionHandler($template->getEncoding());
    $handler->_defaultExceptionHandler($exception);
}


On 2012/05/01, at 23:09, Daniel Jakob wrote:

> On Tue, 2012-05-01 at 12:43 +0000, ajcri...@gmail.com wrote:
>> I highly doubt that apache is seg-faulting. If you are getting a 500 that 
>> could just mean that your error reporting is off.
> 
> You're right for versions prior to 1.2.2. But in the current version, it
> really leads to a crash of the child process. The crash shows up in the
> apache error log.
> 
> [Tue May 01 10:05:06 2012] [notice] child pid 24285 exit signal
> Segmentation fault (11)
> [Tue May 01 10:24:32 2012] [notice] child pid 24252 exit signal
> Segmentation fault (11)
> 
> 
>> 
>> -----Original Message-----
>> From: Daniel Jakob <ja...@sc-networks.com>
>> Sender: phptal-boun...@lists.motion-twin.com
>> Date: Tue, 01 May 2012 10:36:48 
>> To: <phptal@lists.motion-twin.com>
>> Reply-To: Template Attribute Language for PHP <phptal@lists.motion-twin.com>
>> Subject: [PHPTAL] PHP segfaults due Exception in SaxXmlParser
>> 
>> Hi list
>> 
>> After upgrading TAL to 1.2.2, I found a little problem which makes TAL
>> quite unuseable in scenarios, when you are not able to control the given
>> xhtml source. Maybe, the problem depends on newer php versions and/or
>> eaccelerator.
>> 
>> SaxXmlParser::parseString() throws a PHPTAL_ParserException which isn't
>> catched by the try/catch block which leads directly to an apache
>> segfault.
>> The only exception which gets catched is the PHPTAL_TemplateException.
>> The ParserException subclasses the TemplateException but - however - php
>> doesn't care about it. This happens every time when I access the script
>> BUT not the first time. Setting forceReparse to true also 'fixes' the
>> problem so I assume, the problem is somewhere between the phptal cache
>> files and the exceptions in php. Maybe, the eaccelerator is involved,
>> too.
>> What definitely helps is to explicitly catch PHPTAL_ParserException at
>> the end of the switch-block (like the TemplateException does).
>> 
>> A sample:
>> 
>> test.xhtml:
>> 
>> <html>
>> <body>
>> <span style="" style="">I kill the parser</span>
>> </body>
>> </html>
>> 
>> 
>> test.php:
>> 
>> require_once('phptal/PHPTAL.php');
>> $template = new PHPTAL('test.xhtml');
>> $template->setOutputMode(PHPTAL::XML);
>> $template->execute();
>> 
>> 
>> Expected result:
>> PHPTAL Exception
>> Attribute style in < span > is defined more than once
>> 
>> Actual result:
>> Apache segmentation fault
>> 
>> 
>> Used environments:
>> 1. Gentoo amd64, apache 2.22, php 5.3.11, eaccelerator 0.9.6.1
>> 2. Gentoo amd64, apache 2.22, php 5.3.9, eaccelerator 0.9.6.1
>> 3. Ubuntu x86, apache 2.22, php 5.3.6, eaccelerator 0.9.6.1
>> 
>> Maybe, someone has a clue. At least, this report may help anyone having
>> the same problem :)
>> 
>> cu
>> 
>> Daniel
>> 
>> 
>> _______________________________________________
>> PHPTAL mailing list
>> PHPTAL@lists.motion-twin.com
>> http://lists.motion-twin.com/mailman/listinfo/phptal
>> _______________________________________________
>> PHPTAL mailing list
>> PHPTAL@lists.motion-twin.com
>> http://lists.motion-twin.com/mailman/listinfo/phptal
> 
> 
> 
> _______________________________________________
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal

-- 
Hisateru Tanaka
tanakahisat...@gmail.com


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to