httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edward Lu <>
Subject 100% CPU on Win32 processing chunked encoding (trunk)
Date Tue, 20 Jan 2015 20:36:34 GMT
I recently compiled Apache trunk using the CMake build system (which is
excellent, by the way), with the intention of trying to fix up the HTTPD
test framework to work on Windows. One of the tests seems to have caught
something rather severe, with HTTPD threads hanging and taking 100% CPU. It
happens whenever a request with "Transfer-Encoding: Chunked" is received. I
debugged the problem and I think I tracked the cause down.

The infinite loop takes place between ap_discard_request_body() and
ap_http_filter(). For some reason, after reading one chunk,
ap_http_filter() sets ctx->state to -3. This causes the default case to
always be hit in the switch statement in ap_http_filter(), causing
ap_discard_request_body() never to see an EOS and loop infinitely.

ctx->state is only ever set to enum values, so it should never become -3;
however, it turns out that there's an insidious catch relating to
bit-fields and enum values in the Visual Studio compiler. It represents
bitfields of enum types as signed, while the enum values themselves can be
unsigned. The net result is that assigning 5 to a bitfield enum of size 3
actually assigns -3, even if all of the possible enum values are positive.
Apparently, this behavior is technically compliant with the standard;
search around on the web for "enum bitfield signdness".

Back in Apache, I tracked the bug down to r1484852, which introduces the
bitfield enum:

I'm not sure how to go about fixing this. The easiest method appears to be
simply removing the bitfield definition. Hoping for some more experienced
folks to jump in.

View raw message