libmemcache, strtol failed.

Richard Cameron camster at
Tue Aug 16 02:57:08 PDT 2005

On 15 Aug 2005, at 19:25, Paul Quena wrote:

> I am seeing seemingly random failures of libmemcache. We are currently
> using the 1.3.0-rc2 release.
> The error message is:
> mcm_retrive_data():1716 strtol(3) failed: Numerical result out of  
> range:
> invalid flags

I saw a fairly similar bug with an earlier version of libmemcache.  
 From memory it was sporadically seeking too far while trying to read  
data blocks. It seemed to be fairly sporadic in nature because it  
really depended how far the non-blocking read() call got. It all  
depended on operating system and how fast the server could produce  
the next value in the response as to whether it choked or not.

This was quite a while ago (I think I was using libmemcache-1.2.3 at  
the time, but wouldn't swear to it). I committed this patch into my  
own version control system but, for some reason, never got round to  
sending it to the list (perhaps because it only fixed an old  
version). So, it's a slight longshot. You'll need to get hold of an  
old version of the library, apply this patch, and then see if the  
same bug has been translated across directly into the new version...  
and if it's the same problem you're seeing.

--- memcache.c  (revision 2229)
+++ memcache.c  (working copy)
@@ -1070,7 +1070,7 @@
    if (len == 0) {
      /* We haven't yet read a "header" line VALUE ... .. ..\r\n This
       * should be one. Try to match it. */
-    end = memchr(ms->start, (int)'\n', ms->size - (size_t)(ms- 
 >read_cur - ms->buf));
+    end = memchr(cp, (int)'\n', (size_t)(ms->read_cur - cp));
      if(end == NULL) {
        /* No \n yet... keep reading... */
        goto read_more;

More information about the memcached mailing list