Hi ML,
Short version: Increase the default max_input_nesting_level from 100
to something > 150.
Extended version:
I am working on a Compiler written for PHP. Before you criticize me,
let me explain the entire situation.
I work for Doctrine project. Currently we're refactoring the DQL
(Doctrine Query Language) compiler, which processes our SQL-similar
language and convert it into a valid SQL statement for the driver
being used.
If you want a comparative, our approach is inspired in known OQL, like
JPQL of Hibernate in Java.
One example:
SELECT u FROM User u
It'll be converted into something like:
SELECT u.id AS u__id, u.name AS u__name, u.passwd AS u_passwd, u.email
AS u__email FROM user u
Please notice this is a very simple example, but highlights how does it work.
Currently I'm working on the compiler, which has this BNF:
http://trac.doctrine-project.org/browser/trunk/query-language.txt
I've done a lot of optimizations to be able to not touch the default
nesting input level, but doing that I added a lot of restrictions that
now are my bottlenecks.
With all these optimizations, it currently reaches ~70.
I made a lot of tests and the queries usually reaches 103... some
complex ones reached ~140 nested calls.
I know PHP was not structured to build compilers, and also I know this
property can be overrided (many users do not have access to it), but I
think for this situation it worth a consideration.
Also, it's not a simple change for only one user, since our code usage
is very large.
My suggestion is to increase to something like 180, available since PHP 5.3.
I'd like to know your thoughts about this subject.
Thanks in advance,
Best regards,
--
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
Rio de Janeiro - RJ/Brazil
Hi!
Currently I'm working on the compiler, which has this BNF:
http://trac.doctrine-project.org/browser/trunk/query-language.txt
I've done a lot of optimizations to be able to not touch the default
nesting input level, but doing that I added a lot of restrictions that
now are my bottlenecks.
I'm not sure I understand - how this compiler is related to input
nesting level? What exactly you do there that requires 150+ levels of
nesting on input?
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Each grammar rule may forward calls and subsequent things to build itself.
So, ConditionalExpression may forward a call and later call itself
again and again, etc.
At last, the number of nested function calls can easily reach 100.
If you need an example... I can spend some time on it to highlight to you.
Regards,
Hi!
Currently I'm working on the compiler, which has this BNF:
http://trac.doctrine-project.org/browser/trunk/query-language.txt
I've done a lot of optimizations to be able to not touch the default
nesting input level, but doing that I added a lot of restrictions that
now are my bottlenecks.I'm not sure I understand - how this compiler is related to input nesting
level? What exactly you do there that requires 150+ levels of nesting on
input?--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
--
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
Rio de Janeiro - RJ/Brazil
Hi,
He means recursion depth, not input nesting depth. 5.3 had a proposed fast
function call algorithm which would avoid the stack limit and allow deeper
recursion, was this accepted and how does it affect the limit of 100 nested
calls?
Regards,
Stan Vassilev
Hi!
Currently I'm working on the compiler, which has this BNF:
http://trac.doctrine-project.org/browser/trunk/query-language.txt
I've done a lot of optimizations to be able to not touch the default
nesting input level, but doing that I added a lot of restrictions that
now are my bottlenecks.I'm not sure I understand - how this compiler is related to input nesting
level? What exactly you do there that requires 150+ levels of nesting on
input?
Yeah... recursion depth.
Sorry, I wrongly typed it.
I think it may be cleaner now...
On Mon, Sep 8, 2008 at 11:07 PM, Stan Vassilev | FM
sv_forums@fmethod.com wrote:
Hi,
He means recursion depth, not input nesting depth. 5.3 had a proposed fast
function call algorithm which would avoid the stack limit and allow deeper
recursion, was this accepted and how does it affect the limit of 100 nested
calls?Regards,
Stan VassilevHi!
Currently I'm working on the compiler, which has this BNF:
http://trac.doctrine-project.org/browser/trunk/query-language.txt
I've done a lot of optimizations to be able to not touch the default
nesting input level, but doing that I added a lot of restrictions that
now are my bottlenecks.I'm not sure I understand - how this compiler is related to input nesting
level? What exactly you do there that requires 150+ levels of nesting on
input?--
--
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
Rio de Janeiro - RJ/Brazil
Yeah... recursion depth.
Sorry, I wrongly typed it.
I think it may be cleaner now...
Well, PHP itself doesn't protect against this, but my guess is that you
have Xdebug running. Xdebug limits to 100 levels by default in order to
prevent infinite recursion and crashes. Change the
xdebug.max_nesting_level setting to something higher and you'd be good
to go.
regards,
Derick
HEAD before 5_3!: http://tinyurl.com/6d2esb
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org
Derick,
I do not have xdebug installed here.
That's why I thought it was something that could be changed, since
it's something too specific and afaik used only by xdebug.
Regards,
Yeah... recursion depth.
Sorry, I wrongly typed it.
I think it may be cleaner now...
Well, PHP itself doesn't protect against this, but my guess is that you
have Xdebug running. Xdebug limits to 100 levels by default in order to
prevent infinite recursion and crashes. Change the
xdebug.max_nesting_level setting to something higher and you'd be good
to go.regards,
DerickHEAD before 5_3!: http://tinyurl.com/6d2esb
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org
--
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
Rio de Janeiro - RJ/Brazil
There is no nesting limit, it recurses until it runs out of memory.
Derick was saying that XDebug will add one, but other than that there
isn't any.
dev/php53/sapi/cli/php -r 'function m($m) { echo ++$m . " "; m($m); }
m(0); '
I ran that and I got bored when it got to 750,000 levels deep.
Scott
Guilherme Blanco wrote:
Derick,
I do not have xdebug installed here.
That's why I thought it was something that could be changed, since
it's something too specific and afaik used only by xdebug.Regards,
Yeah... recursion depth.
Sorry, I wrongly typed it.
I think it may be cleaner now...
Well, PHP itself doesn't protect against this, but my guess is that you
have Xdebug running. Xdebug limits to 100 levels by default in order to
prevent infinite recursion and crashes. Change the
xdebug.max_nesting_level setting to something higher and you'd be good
to go.regards,
DerickHEAD before 5_3!: http://tinyurl.com/6d2esb
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org
Hm...
Actually at that time I was not able to reproduce the limit, and I
wrote a fix that worked well and reduced the number of nest calls.
Maybe the guy that notified me was using it. Here is the changeset I
did to fix the issue: http://trac.phpdoctrine.org/changeset/4397
But right now I'll have to go back to add some scheduled support, and
I was afraid to fall into the same situation again, and I messaged the
list.
@Derick: If this is a xdebug specific, is there a way to you increase
this number?
Regards,
There is no nesting limit, it recurses until it runs out of memory.
Derick was saying that XDebug will add one, but other than that there
isn't any.dev/php53/sapi/cli/php -r 'function m($m) { echo ++$m . " "; m($m); }
m(0); 'I ran that and I got bored when it got to 750,000 levels deep.
Scott
Guilherme Blanco wrote:
Derick,
I do not have xdebug installed here.
That's why I thought it was something that could be changed, since
it's something too specific and afaik used only by xdebug.Regards,
Yeah... recursion depth.
Sorry, I wrongly typed it.
I think it may be cleaner now...
Well, PHP itself doesn't protect against this, but my guess is that you
have Xdebug running. Xdebug limits to 100 levels by default in order to
prevent infinite recursion and crashes. Change the
xdebug.max_nesting_level setting to something higher and you'd be good
to go.regards,
DerickHEAD before 5_3!: http://tinyurl.com/6d2esb
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org
--
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
Rio de Janeiro - RJ/Brazil
Guilherme Blanco wrote:
Hm...
Actually at that time I was not able to reproduce the limit, and I
wrote a fix that worked well and reduced the number of nest calls.
Maybe the guy that notified me was using it. Here is the changeset I
did to fix the issue: http://trac.phpdoctrine.org/changeset/4397But right now I'll have to go back to add some scheduled support, and
I was afraid to fall into the same situation again, and I messaged the
list.@Derick: If this is a xdebug specific, is there a way to you increase
this number?Regards,
Why? Running xdebug in production environments is not something people
(should) do. And anyone using xdebug is probably smart enough to change
a .ini setting to avoid what you are suggesting. Just add an entry to
your FAQ / Manual about it.
--
Rodrigo Saboya