LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-13-2006, 02:16 AM   #1
byteclock
LQ Newbie
 
Registered: Sep 2005
Posts: 9

Rep: Reputation: 0
Apache and PHP ver 4..looks like a bug...


Hi gurus! I have a hosting server and last month have noticed a weird thing with php and apache. Some of my users creates buggy php pages, which generates in cicle errors , hundreds of MB, which then PHP tries to send to the user!!!! Sure my server dies quickly because those error pages are kept in memory..

I believe you can get down any server you want if for example you run in cicle a

PHP Code:
$handle=fopen(a non-existent url or something not available)
while(!
$feof($handle))
{
//do something

king of that page will run for 30 seconds, this is by default the time a cicle can run, will generate Gigs of errors, which PHP will try to send to the user..I can solve this problem just by dissabling from php.ini display_errors=No..Any other solution??? because i stil want my users to be able to read their errors...

thanks
 
Old 03-13-2006, 07:34 PM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
You can't protect against that kind of coding error; the developer should know to always check the validity of a file handle before using it.

If your developers aren't that sophisticated (amateurs or students) then you need to limit them. You do this by limiting their resources. In this case, I would limit both their memory access and their CPU time; cut the script off at 5 seconds CPU and you'll keep your server alive.
 
Old 03-14-2006, 08:07 AM   #3
byteclock
LQ Newbie
 
Registered: Sep 2005
Posts: 9

Original Poster
Rep: Reputation: 0
well thank you jiml8 for the answer, it seems logical, since nothing could be done to solve that problem, that minimising the run time to 5 sec could stop very nasty scripts. bad programming style or some mistakes sure could not be stopped by any ways.. thank again..
 
Old 03-14-2006, 08:53 AM   #4
onjoo
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Suse 10, Suse-factory , RHEL4, SLES9, SLED10
Posts: 380

Rep: Reputation: 30
Well you can produce the same thing in almost every programming language

Code:
while(true){
 do nothing...
}
That kind of loops can be made. It's just bad coding if you don't check variables in some point or if you let the program run endlessly

You can adjust how php handles the files:
Modify these :
- max_execution_time
- memory_limit

Last edited by onjoo; 03-14-2006 at 08:57 AM.
 
Old 03-15-2006, 07:56 AM   #5
byteclock
LQ Newbie
 
Registered: Sep 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Actually the problem with error output of php engine remains.. I am not a programmer to judge php developers, but i cant undertand how do they allow php to send back hundreds of MB??? On my server a endless loop that runs for 30 sec generates 1-1,5 Gbytes, which then are sent back to the user..how do you like that ????
 
  


Reply



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 On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Upgrading Samba from ver-3.0.4 to current ver-3.0.21b delamatrix SUSE / openSUSE 3 02-20-2006 10:56 AM
Apache getenv bug? wu1821 Linux - General 1 06-29-2005 10:00 AM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
Help with Apache 2+ user cgi (is there a bug?) verbal Linux - Software 1 05-10-2004 04:56 PM
Slackware 9.1 and Apache bug? xipxap Slackware 3 10-14-2003 11:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration