Bug 51904 - output to stderr from cgi script causes script to hang *during uploads*
Summary: output to stderr from cgi script causes script to hang *during uploads*
Status: RESOLVED LATER
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_cgi (show other bugs)
Version: 2.2.17
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: MassUpdate
Depends on:
Blocks:
 
Reported: 2011-09-28 05:33 UTC by Hrunting Johnson
Modified: 2020-01-31 00:44 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hrunting Johnson 2011-09-28 05:33:59 UTC
Similar problems 39342 and 22030.

In 39342, the problem was writing a bunch of data to STDOUT before reading all of STDIN.  I can understand why that would be problematic (output to client before input from client is complete).

I see the same behavior as 39342 when writing a bunch of data to STDERR before fully reading STDIN.  I assume it's the same root issue as 39342: Apache simply doesn't do anything with the CGI script's other file handles (STDOUT *or* STDERR) while it's sending the script the data.

This prevents the CGI script from potentially logging data while it's reading data from Apache.  That functionality shouldn't be prevented.  I can produce a test case if necessary, as I'm hitting the bug today.
Comment 1 William A. Rowe Jr. 2018-11-07 21:08:25 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.
Comment 2 sugar666.sin 2020-01-31 00:44:19 UTC
/  3. The names of the authors may not be used to endorse or promote products
/-        b->last = ngx_http_v2_write_value(b->last, glcf->host.data,
/+    if (ctx == NULL) {
/     u->input_filter = ngx_http_grpc_filter;
/-    ngx_url_t                  u;
/+        } else {
/ #endif
/+    ngx_array_t               *grpc_lengths;
/ } ngx_http_grpc_frame_t;
/+        if (tmp_len < ctx->host.len) {
/+        u->resolved->socklen = url.addrs[0].socklen;
/-    u->ssl = (glcf->upstream.ssl != NULL);
/+    } else if (url.url.len > 8
/+    size_t                add;
/+        sc.values = &glcf->grpc_values;
/+        len += 1 + NGX_HTTP_V2_INT_OCTETS + ctx->host.len;
/     ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
/+        && ngx_strncasecmp(url.url.data, (u_char *) "grpc:/", 7) == 0)
/-        clcf->auto_redirect = 1;
/+                            glcf->grpc_values->elts)
/+    ngx_url_t             url;
/-    clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
/+        u->schema.len = add;
/help
/ }
/ {
/-#else
/     glcf = ngx_http_get_module_loc_conf(r, ngx_http_grpc_module);
/     ngx_http_request_t        *request;
/zip
/@@ -785,7 +901,7 @@
/-    if (glcf->upstream.upstream) {
/     u->input_filter_ctx = ctx;
/+            ctx->host = url.host;
/+    ctx = ngx_http_get_module_ctx(r, ngx_http_grpc_module);
/+        url.url.len -= add;
/tags
/+        u->resolved->name = url.addrs[0].name;
/     u->input_filter_init = ngx_http_grpc_filter_init;
/line wrap: on
/     ngx_str_t                  host;
/         add = 7;
/+        u->schema.data = url.url.data;
/+    ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_grpc_ctx_t));
/     ngx_list_part_t              *part;
/@@ -587,6 +700,7 @@
/-        return NGX_HTTP_INTERNAL_SERVER_ERROR;
/ line diff
/storage/3A44-B2FD/Huawei/Backup/HUAWEI P20 lite__2abb397af5ec3900bd08a331900bfd66075cd1687341ebcafb6049563b997df7/media/doc/Android/data/com.android.gallery3d/files/Log/hwid_advanced_log.txt
/+        r->upstream->ssl = 1;
/Redistribution and use in source and binary forms, with or without
/+    if (clcf->noname
/@@ -4537,18 +4661,54 @@
/+    ngx_url_t                   u;
/author	Vladimir Homutov <vl@nginx.com>
/+        u->ssl = (glcf->upstream.ssl != NULL);
/  1. Redistributions of source code must retain the above copyright notice,
/     u_char                       *p, *tmp, *key_tmp, *val_tmp, *headers_frame;
/THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
/-                       "grpc header: \":authority: %V\"", &glcf->host);
/+    if (n) {
/+    url.no_resolve = 1;
/-    ctx->request = r;
/Mercurial > nginx
/+}
/-    ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_grpc_ctx_t));
/         *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_AUTHORITY_INDEX);
/+{
/children	
/+    return NGX_OK;
/+    if (glcf->upstream.upstream || glcf->grpc_lengths) {
/-        ngx_str_set(&u->schema, "grpcs:/");
/+        clcf->auto_redirect = 1;
/         return "is duplicate";
/-    ngx_str_t                 *value, *url;
/@@ -119,6 +122,8 @@
/+    if (add) {
/     notice, this list of conditions and the following disclaimer in 
/INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
/+    u->resolved->port = url.port;
/+        conf->grpc_lengths = prev->grpc_lengths;
/ static ngx_int_t ngx_http_grpc_reinit_request(ngx_http_request_t *r);
/         ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
/+            ngx_str_set(&u->schema, "grpcs:/");
/ } ngx_http_grpc_ctx_t;
/     this list of conditions and the following disclaimer.
/+    if (u->ssl) {
/     ngx_http_grpc_frame_t        *f;
/INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
/     ngx_http_upstream_t          *u;
/-    ngx_http_core_loc_conf_t  *clcf;
/+    ngx_str_t                  *value, *url;
/+        url.url.data += add;
/         *b->last++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTPS_INDEX);
/         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
/+    ngx_http_core_loc_conf_t   *clcf;
/+    ngx_http_set_ctx(r, ctx, ngx_http_grpc_module);
/+        if (u->ssl) {
/-    if (ctx == NULL) {
/+    ngx_http_upstream_t  *u;
/FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
/+                          "%s in upstream \"%V\"", url.err, &url.url);
/         conf->host = prev->host;
/     /* :authority header *
/changeset 7619:6439ef81e37d tip
/     ngx_uint_t                 host_set;
/     u->output.tag = (ngx_buf_tag_t) &ngx_http_grpc_module;
/     ngx_http_grpc_loc_conf_t *glcf = conf;
/+        conf->grpc_values = prev->grpc_values;
/+            ngx_str_set(&u->schema, "grpc:/");
/-    }
/+        if (ngx_http_grpc_eval(r, ctx, glcf) != NGX_OK) {
/-    if (clcf->lmt_excpt && clcf->handler == NULL && conf->upstream.upstream) {
/     if (!glcf->host_set) {
/gz
/+               && ngx_strncasecmp(url.url.data, (u_char *) "grpcs:/", 8) == 0)
/+        b->last = ngx_http_v2_write_value(b->last, ctx->host.data,
/+        ngx_str_set(&ctx->host, "localhost");
/+        return NGX_HTTP_INTERNAL_SERVER_ERROR;
/+    if (ngx_parse_url(r->pool, &url) != NGX_OK) {
/@@ -4593,14 +4753,6 @@
/     derived from this software without specific prior written permission.
/@@ -4319,15 +4435,23 @@
/+    if (glcf->grpc_lengths == NULL) {
/+        return NGX_CONF_OK;
/@@ -135,6 +140,8 @@
/-        if (tmp_len < glcf->host.len) {
/+    u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
/--- a/src/http/modules/ngx_http_grpc_module.c	Tue Jan 14 14:20:08 2020 +0300
/@@ -577,6 +593,103 @@
/+        ngx_str_set(&u->schema, "grpc:/");
/+    ctx->request = r;
/     url = &value[1];
/-    clcf->handler = ngx_http_grpc_handler;
/+    clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
/-        len += 1 + NGX_HTTP_V2_INT_OCTETS + glcf->host.len;
/over to a BSD-style license. 
/+    if (url.family != AF_UNIX) {
/+            ctx->host.data = url.host.data;
/+        if (ngx_http_script_compile(&sc) != NGX_OK) {
/+        sc.complete_lengths = 1;
/+    n = ngx_http_script_variables_count(url);
/+    if (url.url.len > 7
/         return NGX_HTTP_INTERNAL_SERVER_ERROR;
/-            tmp_len = glcf->host.len;
/-    if (u->ssl) {
/-        ngx_str_set(&u->schema, "grpc:/");
/         conf->upstream.ssl = prev->upstream.ssl;
/diffstat	1 files changed, 193 insertions(+), 41 deletions(-) [+]
/+    ngx_http_script_compile_t   sc;
/+        sc.lengths = &glcf->grpc_lengths;
/         }
/     return NGX_CONF_OK;
/+        u->resolved->sockaddr = url.addrs[0].sockaddr;
/+#if (NGX_HTTP_SSL)
/changeset
/     ngx_uint_t                 ssl;
/+    ngx_array_t               *grpc_values;
/-    if (clcf->noname && conf->upstream.upstream == NULL) {
/gRPC: variables support in the "grpc_pass" directive.
/+                       "grpc header: \":authority: %V\"", &ctx->host);
/     len = sizeof(ngx_http_grpc_connection_start) - 1
/+    if (url.addrs) {
/     ngx_table_elt_t              *header;
/@@ -637,10 +753,10 @@
/+        add = 0;
/+#else
/-    ngx_str_set(&u->schema, "grpc:/");
/     u->finalize_request = ngx_http_grpc_finalize_request;
/@@ -598,6 +712,8 @@
/     ngx_chain_t                  *cl, *body;
/+        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
/     } else {
/+        }
/+++ b/src/http/modules/ngx_http_grpc_module.c	Fri Jan 17 12:13:02 2020 +0300
/+        sc.source = url;
/-    ngx_http_set_ctx(r, ctx, ngx_http_grpc_module);
/+    u->resolved->no_port = url.no_port;
/     value = cf->args->elts;
/+        glcf->ssl = 1;
/  2. Redistributions in binary form must reproduce the above copyright 
/------------------------------------------------------------------------------
/     u = r->upstream;
/OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
/+            return NGX_HTTP_INTERNAL_SERVER_ERROR;
/+            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
/+        ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
/+    ngx_http_grpc_loc_conf_t *glcf)
/+    ngx_str_t                  host;
/date	Fri, 17 Jan 2020 12:13:02 +0300 (3 days ago)
/+    if (clcf->name.len && clcf->name.data[clcf->name.len - 1] == '/') {
/ static ngx_int_t ngx_http_grpc_body_output_filter(void *data, ngx_chain_t *in);
/-                                          glcf->host.len, tmp);
/+        && (conf->upstream.upstream || conf->grpc_lengths))
/-#endif
/         clcf->handler = ngx_http_grpc_handler;
/     unsigned                   status:1;
/Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved.
/parents	8a7b59347401
/     if (ngx_strncasecmp(url->data, (u_char *) "grpc:/", 7) == 0) {
/+        == NULL)
/+            ctx->host.len = url.host.len + 1 + url.port_text.len;
/+    ngx_uint_t                  n;
/bookmarks
/+            return NGX_CONF_ERROR;
/LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
/ ngx_http_grpc_create_request(ngx_http_request_t *r)
/-    size_t                     add;
/+#endif
/@@ -27,6 +27,9 @@
/+                      "grpcs protocol requires SSL support");
/files	src/http/modules/ngx_http_grpc_module.c
/@@ -551,15 +576,6 @@
/log
/+    ngx_memzero(&url, sizeof(ngx_url_t));
/+    if (ngx_http_script_run(r, &url.url, glcf->grpc_lengths->elts, 0,
/+        sc.complete_values = 1;
/         conf->upstream.upstream = prev->upstream.upstream;
/@@ -846,11 +962,11 @@
/           + sizeof(ngx_http_grpc_frame_t);             /* headers frame *
/+    size_t                      add;
/+        sc.cf = cf;
/EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
/+    ngx_http_grpc_ctx_t *ctx, ngx_http_grpc_loc_conf_t *glcf);
/raw
/     ngx_http_script_code_pt       code;
/modification, are permitted provided that the following conditions are met:
/+static ngx_int_t
/+    }
/+        && conf->upstream.upstream == NULL && conf->grpc_lengths == NULL)
/+        u->resolved->naddrs = 1;
/+    {
/INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
/+            tmp_len = ctx->host.len;
/         ngx_str_set(&glcf->host, "localhost");
/+        sc.variables = n;
/ static ngx_int_t
/NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
/+ngx_http_grpc_eval(ngx_http_request_t *r, ngx_http_grpc_ctx_t *ctx,
/ #if (NGX_HTTP_SSL)
/+        return NGX_ERROR;
/+static ngx_int_t ngx_http_grpc_eval(ngx_http_request_t *r,
/-
/@@ -524,22 +531,40 @@
/+    if (clcf->lmt_excpt && clcf->handler == NULL
/     ngx_uint_t                 ssl_protocols;
/+
/+    u = r->upstream;
/+    ngx_http_grpc_ctx_t          *ctx;
/     the documentation and/or other materials provided with the distribution.
/+    } else {
/+                                          ctx->host.len, tmp);
/     u->abort_request = ngx_http_grpc_abort_request;
/JZlib 0.0.* were released under the GNU LGPL license.  Later, we have switched 
/ 
/+        add = 8;
/-    if (clcf->name.len && clcf->name.data[clcf->name.len - 1] == '/') {
/graph
/branches
/+    clcf->handler = ngx_http_grpc_handler;
/+        if (url.err) {
/-    if (glcf->ssl) {
/+    u->resolved->host = url.host;
/+    if (u->resolved == NULL) {
/     }
/+        ctx->host = glcf->host;
/+        if (url.no_port) {
/     clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
/browse
/+        add = 7;
/ static ngx_int_t ngx_http_grpc_create_request(ngx_http_request_t *r);