Bug 44351 - File descriptor leak when using prg RewriteMap
Summary: File descriptor leak when using prg RewriteMap
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite (show other bugs)
Version: 2.2.8
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Keywords: MassUpdate
Depends on:
Reported: 2008-02-04 05:14 UTC by Charles Goyard
Modified: 2018-11-07 21:09 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Charles Goyard 2008-02-04 05:14:09 UTC

There's a file descriptor leak in httpd under Linux when using mod_rewrite's
RewriteMap with prg (external process).

The first prg gets 3 fds (stdin, stdout, stderr).
The second one gets 5 fds (stdin, stdout, stderr + 2 pipes).
The third one gets 7 fds (stdin, stdout, stderr + 2 pipes + 2 pipes).
and so on.

Apache 2.2 spawns one process per prg.
Apache 2.0 spawns one process per prg and per vhost.

Under 2.0 with 85 vhosts and 6 external prg (my setup) gets thousands of fds,
leading to an out of file descriptor error.
This is highly limited with Apache 2.2 but the bug still exists.

With Linux you can get the fd information under /proc/<pid>/fd/.

Here is how I build Apache and a minimalistic httpd.conf that lets one reproduce
the problem.

./configure --with-mpm=prefork --disable-maintainer-mode --disable-access
--disable-auth --disable-include --disable-autoindex --disable-asis
--disable-cgi --disable-negotiation --disable-dir --disable-imap
--disable-actions --disable-userdir --disable-proxy-ftp --disable-proxy-connect
--disable-setenvif --disable-env --disable-mime --disable-so --disable-alias
--enable-headers --enable-proxy --enable-proxy-http --enable-rewrite
--enable-ssl --enable-status

LockFile    var/httpd.lock
PidFile     var/httpd.pid
User  httpd
Group httpd
Listen *:80

RewriteEngine On
RewriteLock var/lbsync.lock
RewriteMap pool1 prg:/usr/local/lb/lb_1
RewriteMap pool2 prg:/usr/local/lb/lb_2
RewriteMap pool3 prg:/usr/local/lb/lb_3

<VirtualHost *>
        ServerName      www.try1.com
        RewriteEngine On

        RewriteRule . http://${pool1:%{ENV:addr}}/$1
        RewriteOptions  inherit


<VirtualHost *>
        ServerName      www.try2.com
        RewriteEngine On

        RewriteRule . http://${pool2:%{ENV:addr}}/$1
        RewriteOptions  inherit

<VirtualHost *>
        ServerName      www.try3.com
        RewriteEngine On

        RewriteRule . http://${pool3:%{ENV:addr}}/$1
        RewriteOptions  inherit

<VirtualHost *>
        ServerName      www.try4.com
        RewriteEngine On
        RewriteRule . http://${pool1:%{ENV:addr}}/$1
        RewriteOptions  inherit

<VirtualHost *>
        ServerName      www.try5.com
        RewriteRule . http://${pool1:%{ENV:addr}}/$1
        RewriteOptions  inherit



Comment 1 William A. Rowe Jr. 2018-11-07 21:09:16 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.