Bug 822910 - Timeout Option tiggers a false 504 Gateway error
Timeout Option tiggers a false 504 Gateway error
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: httpd (Show other bugs)
16
All Linux
unspecified Severity low
: ---
: ---
Assigned To: Joe Orton
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-18 09:29 EDT by customercare
Modified: 2013-02-13 10:10 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-13 10:10:49 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description customercare 2012-05-18 09:29:58 EDT
Description of problem:

A low value of Timeout tiggers a 504 Gateway error , instead of killing the prozess after the Timeoutvalue.

In other words, the executed script terminates long after the timeout value correctly, but still gets a 504 message.


Version-Release number of selected component (if applicable):

# cat /etc/issue
Fedora release 16 (Verne) 
# httpd -v
Server version: Apache/2.2.22 (Unix)
Server built:   Mar  5 2012 10:52:49   

How reproducible:

always.

Steps to Reproduce:
1.

For this example , set Timeout in the httpd.conf  like this:

Timeout = 10

2.

have a vhost like this : 

<VirtualHost *:80>
    ServerAdmin XXXXXXXXXXXXX
    SSLProxyEngine On
    DocumentRoot XXXXXXXXXXXXX
    ServerName XXXXXXXXXXXXX
    ServerAlias *.XXXXXXXXXXXXX
    ErrorLog logs/error_log
    CustomLog domlogs/XXXXXXXXXXXXX combined
        <Directory /home/XXXXXXXXXXXXX/public_html>

                ... options as you like and need ....

                AddHandler php-script .php .pl .rb .py .exe .cgi .sh
                Action php-script /cgi-sys/cgiwrap

        </Directory>
</VirtualHost>

cgiwrap 

- set the userlimits 
- does a chroot() 
- and starts the php interpreter like this : 
  execve("/usr/bin/php-cgi", newargv, environ); 

Works like a charm, no faults known and NOT CAUSE of the problem.

3.

Write a script like this :

<?php

sleep ( 9 );

phpinfo();

?> 

This WORKS ... you get the phpinfo() output in your browser.

<?php

sleep ( 30 );

phpinfo();

system("echo 1 >/tmp/one");

?> 

Executes for 30 Seconds, then you end up with a 504 Gateway Timeout Message from Apache. 

BUT .. system("echo 1 >/tmp/one"); executes at the end of the script as it should. You get a file in /tmp/  as expected. 

This means, the 504 message is wrongly applied, and the timeout did not work at all :) 
 
Actual results:

504 Gateway Timeout messages after the script terminated correctly.

Expected results:

depends on how seriose you take the name of the option "Timeout"..

a) stop the execution of a script after this value ( must be useable in vhosts )
or 
b) (prefered) get rid of the wronly applied message, if the script terminated without error. 

Remark:

It's not a fedora problem, i believe it's a logic problem inside apache sources.. You can redirect it directly to the apache team.
Comment 1 Joe Orton 2012-06-06 12:04:07 EDT
On expiry of the timeout reading from the CGI script, httpd will send a SIGTERM signal to the CGI process.   I confirmed that still works with:

httpd-2.2.22-4.fc17.x86_64

What version of php are you using?  Can you provide "strace" output from the running php-cgi process?   Run:

  # strace -p `pidof php-cgi`

once the process is running.

I'm not sure why it would be ignoring SIGTERM.
Comment 2 customercare 2012-06-06 12:48:35 EDT
I used a curl on my server to start the script and curl returned after app. 10 secs with the 504 .. the php was still running.

I can't see a SIGTERM to the process, if i'm correct, i won't wonder. 

This starts the php-cgi : 

                newargv[0] = "/usr/bin/php-cgi";
                execve("/usr/bin/php-cgi", newargv, environ);  

IF thats leeds to a new pid, than the apache may try to kill something thats not there or worse, a new process spawned from someone else :)

Only the PIPE will be keept open to retrieve the scriptoutput.

Can you confirm this ?

BTW: Removing the Timeout option from the config solves it. 

installed: systemside

httpd-2.2.22-2.fc16.x86_64

installed: chroot

# /opt/root/usr/bin/php-cgi -v
PHP 5.3.11 (cgi-fcgi) (built: Apr 27 2012 15:09:32)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies 

This is the strace result , made it twice , same result : 

Process 10387 attached
restart_syscall(<... resuming interrupted call ...>) = 0
uname({sys="Linux", node="xXxXxXxXxXxXxXx", ...}) = 0
write(1, "X-Powered-By: PHP/5.3.11", 24) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=10387, si_uid=1001} ---
chdir("/")                              = 0
munmap(0x7f230b271000, 528384)          = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
munmap(0x7f230c900000, 2181208)         = 0
munmap(0x7f230d3e2000, 2131216)         = 0
munmap(0x7f230d1ce000, 2177680)         = 0
munmap(0x7f230cf92000, 2342104)         = 0
munmap(0x7f230cd19000, 2591648)         = 0
munmap(0x7f230cb15000, 2109528)         = 0
munmap(0x7f230d5eb000, 2143152)         = 0
munmap(0x7f230d7f7000, 2126896)         = 0
munmap(0x7f230d9ff000, 2130656)         = 0
munmap(0x7f230dc08000, 2145480)         = 0
munmap(0x7f230de14000, 2360656)         = 0
munmap(0x7f230e2f4000, 2122888)         = 0
munmap(0x7f230e055000, 2745496)         = 0
munmap(0x7f230e4fb000, 2127024)         = 0
munmap(0x7f230e703000, 2197640)         = 0
munmap(0x7f230e91c000, 2233648)         = 0
munmap(0x7f230f01b000, 2151592)         = 0
munmap(0x7f230eb3e000, 5098872)         = 0
munmap(0x7f230f45b000, 2143128)         = 0
munmap(0x7f230f229000, 2299776)         = 0
munmap(0x30dac00000, 2132040)           = 0
munmap(0x7f230f667000, 4255792)         = 0
munmap(0x7f230fa77000, 2130400)         = 0
munmap(0x7f2310d06000, 2451488)         = 0
munmap(0x3b69c00000, 2478920)           = 0
munmap(0x7f2310a67000, 2745976)         = 0
munmap(0x3b6a400000, 2164440)           = 0
munmap(0x7f2310729000, 3399408)         = 0
munmap(0x7f2310502000, 2253832)         = 0
munmap(0x7f23102b3000, 2417312)         = 0
munmap(0x7f2310098000, 2206544)         = 0
munmap(0x7f230fc80000, 2106112)         = 0
munmap(0x7f2310f5d000, 4471120)         = 0
munmap(0x7f23113a1000, 2273776)         = 0
munmap(0x7f2312088000, 2168072)         = 0
munmap(0x30da800000, 2473448)           = 0
munmap(0x7f2311e56000, 2301688)         = 0
munmap(0x30da000000, 2413736)           = 0
munmap(0x30d9c00000, 2155816)           = 0
munmap(0x30d9800000, 2343088)           = 0
munmap(0x7f2311c2a000, 2276448)         = 0
munmap(0x30d9000000, 3372744)           = 0
munmap(0x30d9400000, 2251040)           = 0
munmap(0x30d8c00000, 2109784)           = 0
munmap(0x7f2311a25000, 2113912)         = 0
munmap(0x7f23117e8000, 2346304)         = 0
munmap(0x30da400000, 2250048)           = 0
munmap(0x7f23115cd000, 2205616)         = 0
munmap(0x7f231229a000, 323584)          = 0
exit_group(0)                           = ?
+++ exited with 0 +++
Comment 3 customercare 2012-06-26 07:17:41 EDT
component changed, as it's not php related, it's a (apache)httpd problem.
Comment 4 customercare 2012-06-26 07:19:50 EDT
bugzilla changed the component to "zzuf" WHY ???????
Comment 5 customercare 2012-10-18 08:34:36 EDT
*PUSH*
Comment 6 Fedora End Of Life 2013-01-16 09:09:24 EST
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 7 Fedora End Of Life 2013-02-13 10:10:52 EST
Fedora 16 changed to end-of-life (EOL) status on 2013-02-12. Fedora 16 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.