master/jstree Faulting Apache with Wampserver

22 views
Skip to first unread message

Hamish Campbell

unread,
Mar 15, 2011, 3:51:32 PM3/15/11
to SilverStripe Core Development
Hey all,

Just a quick question - is anyone using Wampserver (any version)
experiencing issues with the master or jstree builds? I'm getting hard
application errors (application crash in httpd.exe) and nothing useful
out. Slowly narrowing it down to somewhere within the Controller stack
(perhaps in handleAction) - but wondered if anyone was experiencing
this and knew what the issue was.

Regards

Hamish Campbell

Hamish Campbell

unread,
Mar 15, 2011, 4:54:13 PM3/15/11
to SilverStripe Core Development
Ah, it is happening in SSTemplateParser - somewhere in
match_TopTemplate. Hamish, any clues on how to debug, perhaps some
easy way to record the parser state? I'm not getting any useful errors
thrown so I'm basically throwing in exit; to see where it's failing,
but doing that for the multiple nested whiles isn't practical (it
doesn't happen on the first pass). There is some condition being
reached in the loop that is causing an application crash. I've tried
PHP 5.3.0 and 5.3.5, and apache 2.2.11 and 2.2.17 on windows.

Regards

Hamish Campbell

Sam Minnée

unread,
Mar 15, 2011, 5:09:17 PM3/15/11
to silverst...@googlegroups.com
Do you have xdebug installed to use with interactive debugging?  Can you single-step through the code to find the point at which it's crashing?

Usually I've found these errors occur when new classes are being loaded too deep within the call-stack, or something, and that the fix it to make an appropriate class_exists() call further up the call-stack to load the relevant class.

--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To post to this group, send email to silverst...@googlegroups.com.
To unsubscribe from this group, send email to silverstripe-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/silverstripe-dev?hl=en.


Hamish Friedlander

unread,
Mar 15, 2011, 5:17:50 PM3/15/11
to silverst...@googlegroups.com, Sam Minnée
You can also turn on template debugging by adding this to the top of SSTemplateParser.php.inc just after the opening php tag:

/*!* !debug */

Then run "php ../thirdparty/php-peg/cli.php SSTemplateParser.php.inc > SSTemplateParser.php" in the sapphire/core directory.

Debug mode is very noisy, so it might be worth getting as small an example as possible that still crashes, write a test that uses that example, then try debugging mode on it.

If you can narrow it down to a small example I'm happy to see if I can spot anything.

Hamish Friedlander
SilverStripe

Marcus Nyeholt

unread,
Mar 15, 2011, 6:21:12 PM3/15/11
to silverst...@googlegroups.com, Sam Minnée
Funnily enough, that seems to be the cause of most segfaults for me too - any idea what the root cause is? It's nice that there's a simple workaround, but bloody frustrating :)

Hamish Campbell

unread,
Mar 16, 2011, 12:41:35 AM3/16/11
to SilverStripe Core Development
Hey,

So it's not a call stack depth issue - it seems to be a regular
expression problem.

The following gist is a script that crashes Apache on windows:

https://gist.github.com/872020

It appears that the token on line 7 "(<[^%])" is causing the issue,
removing it allows the script to run. Removing the free-spacing
modifier (x) also lets it run, but it seems less likely that this is
the cause.

Ideas?

Hamish

On Mar 16, 10:17 am, Hamish Friedlander <ham...@silverstripe.com>
wrote:
> You can also turn on template debugging by adding this to the top of
> SSTemplateParser.php.inc just after the opening php tag:
>
> /*!* !debug */
>
> Then run "php ../thirdparty/php-peg/cli.php SSTemplateParser.php.inc >
> SSTemplateParser.php" in the sapphire/core directory.
>
> Debug mode is very noisy, so it might be worth getting as small an example
> as possible that still crashes, write a test that uses that example, then
> try debugging mode on it.
>
> If you can narrow it down to a small example I'm happy to see if I can spot
> anything.
>
> Hamish Friedlander
> SilverStripe
>
> On 16 March 2011 10:09, Sam Minnée <s...@silverstripe.com> wrote:
>
>
>
>
>
>
>
> > Do you have xdebug installed to use with interactive debugging?  Can you
> > single-step through the code to find the point at which it's crashing?
>
> > Usually I've found these errors occur when new classes are being loaded too
> > deep within the call-stack, or something, and that the fix it to make an
> > appropriate class_exists() call further up the call-stack to load the
> > relevant class.
>
> > Here's an example:
> >https://github.com/silverstripe/silverstripe-cms/blob/master/code/Wid...

Sam Minnée

unread,
Mar 16, 2011, 3:38:56 PM3/16/11
to silverst...@googlegroups.com
Hamish F, shouldn't those $s outside of []s be escaped?

Hamish C, do the SSViewer tests pass on your machine?

On 16/03/2011, at 10:09 PM, Hamish Campbell <hn.ca...@gmail.com> wrote:

> Heh, is Simon having similar issues?
>
> http://bugs.php.net/bug.php?id=53635
>
> Some more info. The x modifier is definitely not the cause, the
> following will also fail:
>
> /((\\.)|([^<${])|(<[^%])|($[^A-Za-z_])|({[^$])|({$[^A-Za-z_]))+/S
>
> Also - removing either the second "([^<${])" or third token
> (previously mentioned) stops the error.
>
> I've tried bumping up pcre.backtrack_limit and PHP's memory_limit, on
> the off chance that would help.
>
> To add insult to injury, running the test script via php-cli works,
> which implies (to me) that it's not a PCRE bug.
>
> Anyone know if master works from IIS?
>
> Hamish

Hamish Friedlander

unread,
Mar 16, 2011, 5:08:33 PM3/16/11
to silverst...@googlegroups.com, Sam Minnée
On 17 March 2011 08:38, Sam Minnée <s...@silverstripe.com> wrote:
Hamish F, shouldn't those $s outside of []s be escaped?

Yes, they should. I'll commit a patch once I can work up a failing test. Don't know if that'll solve the segfault though - Hamish C, if you change that regex to:

/((\\.)|([^<${])|(<[^%])|(\$[^A-Za-z_])|({[^$])|({\$[^A-Za-z_]))+/S

Does it still crash?

Hamish Friedlander
SilverStripe

Hamish Campbell

unread,
Mar 16, 2011, 5:33:18 PM3/16/11
to SilverStripe Core Development
Sam, SSViewer tests also crash Apache.

Hamish, yes I tried making removing the x modifier (with comments and
whitespace) and added more rigorous escaping, didn't help.

For no reason that I can ascertain that particular test script now
runs on my work machine - I didn't even shut the thing down overnight
- but the issue is still happening with the same regex and content
within SilverStripe.

I've put a dump of the ParseRegexp state immediately before the crash:

https://gist.github.com/873351

Or, serialized

https://gist.github.com/873359

I will then crash on:

$matched = preg_match( $this->rx, $this->parser->string, $this-
>matches, PREG_OFFSET_CAPTURE, $this->check_pos) ;

Hamish Campbell

On Mar 17, 10:08 am, Hamish Friedlander <ham...@silverstripe.com>
wrote:

Hamish Friedlander

unread,
Mar 16, 2011, 8:41:55 PM3/16/11
to silverst...@googlegroups.com
OK, managed to replicate the problem. It's definitely something to do with PCRE, but I couldn't find a PCRE-based workaround. 

Instead I've changed the Text rule to avoid the problem. Fixed some text escaping bugs at the same time. Change set is at https://github.com/silverstripe/sapphire/commit/88535a43c57b80d0a2d33d05265cf6165cc93564

Let me know if that fixed the segfault for you as well.

Hamish Friedlander
SilverStripe

Hamish Campbell

unread,
Mar 16, 2011, 9:45:39 PM3/16/11
to SilverStripe Core Development
Brilliant, thank you Hamish, I'm back in business =D

Ingo, when you have a minute, push that into jstree and I'll be able
to have a look at some of the items on the list this weekend.

Hamish Campbell

On Mar 17, 1:41 pm, Hamish Friedlander <ham...@silverstripe.com>
wrote:
> OK, managed to replicate the problem. It's definitely something to do with
> PCRE, but I couldn't find a PCRE-based workaround.
>
> Instead I've changed the Text rule to avoid the problem. Fixed some text
> escaping bugs at the same time. Change set is athttps://github.com/silverstripe/sapphire/commit/88535a43c57b80d0a2d33...
>
> Let me know if that fixed the segfault for you as well.
>
> Hamish Friedlander
> SilverStripe
>

Hamish Campbell

unread,
Mar 16, 2011, 5:09:07 AM3/16/11
to SilverStripe Core Development
Heh, is Simon having similar issues?

http://bugs.php.net/bug.php?id=53635

Some more info. The x modifier is definitely not the cause, the
following will also fail:

/((\\.)|([^<${])|(<[^%])|($[^A-Za-z_])|({[^$])|({$[^A-Za-z_]))+/S

Also - removing either the second "([^<${])" or third token
(previously mentioned) stops the error.

I've tried bumping up pcre.backtrack_limit and PHP's memory_limit, on
the off chance that would help.

To add insult to injury, running the test script via php-cli works,
which implies (to me) that it's not a PCRE bug.

Anyone know if master works from IIS?

Hamish

On Mar 16, 5:41 pm, Hamish Campbell <hn.campb...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages