Infinite PHP function stack crashes Apache in Vista - Fixable?

This is a discussion on Infinite PHP function stack crashes Apache in Vista - Fixable? within the Apache Web Server forums, part of the Web Server and Related Forums category; The following PHP code causes Apache to crash and PHP to suspend: a() ; function a(){return a();} This is running ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-09-2008
PHPBABY3
 
Posts: n/a
Default Infinite PHP function stack crashes Apache in Vista - Fixable?


The following PHP code causes Apache to crash and PHP to suspend:

a() ; function a(){return a();}

This is running EasyPHP under Vista.

How to fix?

Thanks,

P.
  #2 (permalink)  
Old 02-09-2008
Luuk
 
Posts: n/a
Default Re: Infinite PHP function stack crashes Apache in Vista - Fixable?

PHPBABY3 schreef:
> The following PHP code causes Apache to crash and PHP to suspend:
>
> a() ; function a(){return a();}
>



what do you expect this code to do?

--
Luuk
  #3 (permalink)  
Old 02-09-2008
ed
 
Posts: n/a
Default Re: Infinite PHP function stack crashes Apache in Vista - Fixable?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

PHPBABY3 wrote:
> The following PHP code causes Apache to crash and PHP to suspend:
>
> a() ; function a(){return a();}
>
> This is running EasyPHP under Vista.
>
> How to fix?
>
> Thanks,
>
> P.


The code is recursive.

The function a has to call a to get it's return value.

It will never return.

- --
The T3 to Qwicky Mart is wigging because of burned out dilithium crystals.
The T1000 is blaming George Lucas.
:: http://www.s5h.net/ :: http://www.s5h.net/gpg.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHrd+M4dyr7s6PRYgRAgfNAJ9wvLjLO/MyOsOOJv82u9Vr82oVfQCfbirI
6GZduUj/3cOxzodp1ddIxMo=
=6HFh
-----END PGP SIGNATURE-----
  #4 (permalink)  
Old 02-09-2008
Kees Nuyt
 
Posts: n/a
Default Re: Infinite PHP function stack crashes Apache in Vista - Fixable?

On Sat, 9 Feb 2008 07:59:51 -0800 (PST), PHPBABY3
<shymathguy@gmail.com> wrote:

>
>The following PHP code causes Apache to crash and PHP to suspend:
>
>a() ; function a(){return a();}


Any language would either crash on this (stack overflow),
or never finish (auto-optimized recursion to iteration).

>This is running EasyPHP under Vista.
>
>How to fix?


Add an end condition to function a() which stops the
recursion, so the nesting is limited.

It shouldn't crash Apache, it should only crash the PHP
script. The only reason I can think of is a too high
memory limit in php.ini
But that's more a comp.lang.php question.
Cross-posted to comp.lang.php and followup-to set.

>Thanks,
>
>P.

--
( Kees
)
c[_] I have a rock garden. 3 of them died last week. (#176)
  #5 (permalink)  
Old 02-09-2008
phantom
 
Posts: n/a
Default Re: Infinite PHP function stack crashes Apache in Vista - Fixable?

"PHPBABY3" <shymathguy@gmail.com> wrote in message
news:8879c1fe-4041-40af-93ff-56b2b9036747@u10g2000prn.googlegroups.com...
>
> The following PHP code causes Apache to crash and PHP to suspend:
>
> a() ; function a(){return a();}
>
> This is running EasyPHP under Vista.
>
> How to fix?
>


Assuming your code snippet is complete, rather than a cut down (missing any
relevant detail)...
put two slashes at the start of the line -
//a() ; function a(){return a();}

or delete the line completely.


  #6 (permalink)  
Old 02-09-2008
PHPBABY3
 
Posts: n/a
Default Re: Infinite PHP function stack crashes Apache in Vista - Fixable?

On Feb 9, 3:17*pm, "phantom" <nob...@blueyonder.invalid> wrote:
> "PHPBABY3" <shymath...@gmail.com> wrote in message
>
> news:8879c1fe-4041-40af-93ff-56b2b9036747@u10g2000prn.googlegroups.com...
>
>
>
> > The following PHP code causes Apache to crash and PHP to suspend:

>
> > a() ; function a(){return a();}

>
> > This is running EasyPHP under Vista.

>
> > How to fix?

>
> Assuming your code snippet is complete, rather than a cut down (missing any
> relevant detail)...
> put two slashes at the start of the line -
> //a() ; function a(){return a();}
>
> or delete the line completely.


But what about my experiment in Computability Theory?

P.



  #7 (permalink)  
Old 02-10-2008
Kees Nuyt
 
Posts: n/a
Default Re: Infinite PHP function stack crashes Apache in Vista - Fixable?

On Sat, 9 Feb 2008 14:07:45 -0800 (PST), PHPBABY3
<shymathguy@gmail.com> wrote:

>On Feb 9, 3:17*pm, "phantom" <nob...@blueyonder.invalid> wrote:
>> "PHPBABY3" <shymath...@gmail.com> wrote in message
>>
>> news:8879c1fe-4041-40af-93ff-56b2b9036747@u10g2000prn.googlegroups.com...
>>
>> > The following PHP code causes Apache to crash and PHP to suspend:

>>
>> > a() ; function a(){return a();}

>>
>> > This is running EasyPHP under Vista.

>>
>> > How to fix?

>>
>> Assuming your code snippet is complete, rather than a cut down (missing any
>> relevant detail)...
>> put two slashes at the start of the line -
>> //a() ; function a(){return a();}
>>
>> or delete the line completely.

>
>But what about my experiment in Computability Theory?
>
>P.


Off topic in alt.apache.configuration, but it succeeded.
You already stated the function will never return, so
there is no computable result ("mathematical proof").

What's more, you showed that PHP doesn't optimize
a() ; function a(){return a();}
out of the program.

In C the compiler should optimize it out, because
a();
isn't used anywhere.
--
( Kees
)
c[_] The amount of time between slipping on the peel and
landing on the pavement is precisely one bananosecond. (#72)
  #8 (permalink)  
Old 02-10-2008
PHPBABY3
 
Posts: n/a
Default Re: Infinite PHP function stack crashes Apache in Vista - Fixable?

On Feb 10, 5:39*am, Kees Nuyt <k.n...@nospam.demon.nl> wrote:
> On Sat, 9 Feb 2008 14:07:45 -0800 (PST), PHPBABY3
>
>
>
>
>
> <shymath...@gmail.com> wrote:
> >On Feb 9, 3:17*pm, "phantom" <nob...@blueyonder.invalid> wrote:
> >> "PHPBABY3" <shymath...@gmail.com> wrote in message

>
> >>news:8879c1fe-4041-40af-93ff-56b2b9036747@u10g2000prn.googlegroups.com....

>
> >> > The following PHP code causes Apache to crash and PHP to suspend:

>
> >> > a() ; function a(){return a();}

>
> >> > This is running EasyPHP under Vista.

>
> >> > How to fix?

>
> >> Assuming your code snippet is complete, rather than a cut down (missingany
> >> relevant detail)...
> >> put two slashes at the start of the line -
> >> //a() ; function a(){return a();}

>
> >> or delete the line completely.

>
> >But what about my experiment in Computability Theory?

>
> >P.

>
> Off topic in alt.apache.configuration,


How is one to know if there is a solution involving the
configuration? Maybe disable a non-essential feature and it runs into
a protected memory error instead of overwriting its own code and
crashing?

> but it succeeded.
> You already stated the function will never return, so
> there is no computable result ("mathematical proof").


To remove that possibility (a function gets in an infinite loop), you
would have to have a program tell you if your program is in an
infinite loop. Turing proved that impossible in 1937 (although PHP
wasn't that popular then.)

P.

> What's more, you showed that PHP doesn't optimize
> * * * * a() ; function a(){return a();}
> out of the program.
>
> In C the compiler should optimize it out, because
> * * * * a();
> isn't used anywhere.
> --
> *( *Kees
> * )
> c[_] The amount of time between slipping on the peel and
> * * *landing on the pavement is precisely one bananosecond. *(#72)- Hide quoted text -
>
> - Show quoted text -


  #9 (permalink)  
Old 02-10-2008
Kees Nuyt
 
Posts: n/a
Default Re: Infinite PHP function stack crashes Apache in Vista - Fixable?

On Sun, 10 Feb 2008 06:52:29 -0800 (PST), PHPBABY3
<shymathguy@gmail.com> wrote:

>On Feb 10, 5:39*am, Kees Nuyt <k.n...@nospam.demon.nl> wrote:
>> On Sat, 9 Feb 2008 14:07:45 -0800 (PST), PHPBABY3
>>
>> Off topic in alt.apache.configuration,

>
>How is one to know if there is a solution involving the
>configuration? Maybe disable a non-essential feature and it runs into
>a protected memory error instead of overwriting its own code and
>crashing?


I don't know of any configuration options in Apache to
limit the privileges of a program other than the userID in
which CGIs are launched and what the operating system
offers.

PHP does have some options (memory usage, timeout), but
that's off topic here.

>> but it succeeded.
>> You already stated the function will never return, so
>> there is no computable result ("mathematical proof").

>
>To remove that possibility (a function gets in an infinite loop), you
>would have to have a program tell you if your program is in an
>infinite loop. Turing proved that impossible in 1937 (although PHP
>wasn't that popular then.)


I double qouted "mathematical proof" on purpose.
Turings proof is probably meant in the general case of an
unknown program. In this case you carefully crafted an
infinite recursion on purpose. And you apparently
succeeded.

I don't think a detailed discussion on Turing etc. is on
topic in alt.apache.configuration.

As I said before, I don't know of any way to prevent
Apache crashing on this in httpd.conf, so this will
probably be my last contribution to this thread.
--
( Kees
)
c[_] Crime does not pay...as well as politics. (#356)
  #10 (permalink)  
Old 04-17-2008
fwahdlyhq
 
Posts: n/a
Default fwahdlyhq

V0wwqD <a href="http://rfdcxmqlkbiu.com/">rfdcxmqlkbiu</a>,
cgpsylopjgec,
[link=http://micjvehohqci.com/]micjvehohqci[/link],
http://voaswcsnbmnx.com/

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:59 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0