Re: [PATCH] http-backend: Don't infinite loop during die()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 24, 2010, 18:29 UTC
- Message-ID
- <7vvdclk1y9.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20100322142204.GB8916@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 9 quoted lines
> If stdout has already been closed by the CGI and die() gets called, > the CGI will fail to write the "Status: 500 Internal Server Error" to > the pipe, which results in die() being called again (via safe_write). > This goes on in an infinite loop until the stack overflows and the > process is killed by SIGSEGV. > > Instead set a flag on the first die() invocation and perform no > action during recursive die() calls. This way failures to write the > error messages to the stdout pipe do not result in an infinite loop.
Hmm. I would need something like this on top, but there must be a better way. Ideas?
-- >8 -- Subject: [PATCH] fixup! http-backend.c: Don't infinite loop
Now die_webcgi() actually can return during a recursive call into it, causing
http-backend.c:554: error: 'noreturn' function does return
Work it around with a somewhat ugly workaround.
Signed-off-by: Junio C Hamano <gitster@pobox.com> --- http-backend.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/http-backend.c b/http-backend.c index f4d49b6..d3ec6f0 100644 --- a/http-backend.c +++ b/http-backend.c @@ -536,7 +536,7 @@ static void service_rpc(char *service_name) strbuf_release(&buf); } -static NORETURN void die_webcgi(const char *err, va_list params) +static void die_webcgi(const char *err, va_list params) { static int dead; @@ -606,7 +606,7 @@ int main(int argc, char **argv) int i; git_extract_argv0_path(argv[0]); - set_die_routine(die_webcgi); + set_die_routine((void *)die_webcgi); if (!method) die("No REQUEST_METHOD from server");
-- 1.7.0.3.435.g097f4