View Issue Details

IDProjectCategoryView StatusLast Update
0002085libmicrohttpdexternal even looppublic2012-01-23 13:21
Reportertclaveirole Assigned ToChristian Grothoff Due Date
PrioritynormalSeverityminorReproducibilitysometimes
Status closedResolutionfixed 
Product Version0.9.17 
Target Version0.9.18Fixed in Version0.9.18 
Summary0002085: MHD_get_timeout relies on uninitialized variable, leads to busy waiting sometimes
DescriptionThe earliest_deadline variable in MHD_get_timeout (src/daemon/daemon.c, line 1204) is not initialized. Therefore, the comparison on line 1223 is invalid. On some occasions (e.g., earliest_deadline's first value is zero), this leads to returning an incorrect timeout. Sometimes this incorrect timeout is constantly zero and the HTTP server starts busy waiting.
Steps To ReproduceBecause this bug depends on the state of an uninitialized variable, it is sometimes hard to reproduce. Here are steps that triggers the bug every time on my machine (Debian i386 testing, with Debian GCC 4.6.2-11).

1. Use a libmicrohttpd that has optimizations disabled (i.e., compiled with -O0. Else the uninitialized variable goes into a register and the result is unpredictable).

2. Compile and run the attached test.c. This is a simple HTTP server that uses libmicrohttpd with external select and connection timeouts. Each time MHD_get_timeout returns a valid timeout with value 0, the server prints a '.' character. The server never replies to requests (so it should close HTTP connections abruptly when their timeouts expire).

3. Make a request to the server. The server then busy waits: it prints a lot of '.' until the timeout is reached and the connection closed. At this point, it goes back to using select() with no timeout. This is not the expected behavior. As nothing is done to reply to the request, the server should have spent most of its time blocked in select() with a proper timeout.
Additional InformationAttached is a patch that solves that bug.
TagsNo tags attached.
Attached Files
attachments.tar (10,240 bytes)

Relationships

related to 0002018 closedChristian Grothoff GNUnet http(s) transport eats cpu 

Activities

Christian Grothoff

2012-01-19 16:47

manager   ~0005296

Fixed in SVN 19263.

Issue History

Date ModifiedUsernameFieldChange
2012-01-19 14:38tclaveiroleNew Issue
2012-01-19 14:38tclaveiroleFile Added: attachments.tar
2012-01-19 16:33Christian GrothoffTarget Version => 0.9.18
2012-01-19 16:34Christian GrothoffAssigned To => Christian Grothoff
2012-01-19 16:34Christian GrothoffStatusnew => assigned
2012-01-19 16:47Christian GrothoffNote Added: 0005296
2012-01-19 16:47Christian GrothoffStatusassigned => resolved
2012-01-19 16:47Christian GrothoffFixed in Version => 0.9.18
2012-01-19 16:47Christian GrothoffResolutionopen => fixed
2012-01-19 21:21Christian GrothoffRelationship addedrelated to 0002018
2012-01-23 13:21Christian GrothoffStatusresolved => closed
2013-05-06 10:52Christian GrothoffCategoryexternal select => libmicrohttpd external select
2024-01-21 12:24Christian GrothoffCategorylibmicrohttpd external select => external even loop