Skip to content

uint32_t overflow cause busy loop in 1.0.18 #62

@m6w6

Description

@m6w6

Imported from Launchpad using lp2gh.


We are using libmemcached 1.0.18 and observed occasionally very high CPU consumption.
After some debugging, the cause is located in libmemcached/purge.cc :

bool memcached_purge(memcached_instance_st* ptr)
{
    .............
    uint32_t no_msg= memcached_server_response_count(ptr) - 1;
   for (uint32_t x= 0; x < no_msg; x++)     // busy loop here 
   {
         .....
   }
}

During debugging, we found that memcached_server_response_count(ptr) sometimes return a large value which equals to (uint32_t)(0-1) .

In order to fix this issue, we took an quick & dirty solution, which refuses to decrement by 1 when 0. This patch is attached below.

But still, I haven't found the root cause, and I'm afraid the root cause would leads to more possible hidden issues. So hope someone else could catch and fix this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions