|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59356 cas_token overflowed and missed cas command
Submitted: 2010-08-10 06:53 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: isao dot kata at gmail dot com Assigned:
Status: Open Package: memcached (PECL)
PHP Version: 5.2.13 OS: Linux / CentOS 5.4
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-08-10 06:53 UTC] isao dot kata at gmail dot com

I was encountered that "cas_token" overflowed and missed cas 
command when I used "kumofs", a distributed key-value store 
which supports memcached text protocol.

It seems that kumofs returns cas_token within uint64_t 
range, protocols are as follows.

telnet localhost 11311
VERSION kumofs-0.4.11
gets cas_count
VALUE cas_count 1 2 5503666394124107763

Pecl::Memcached seems to cast type of "cas_token" from 
uint64_t to double, but in PHP, cas_token isn't precisely 
equal value expected. I wonder it is because of overflow 
occured in casting uint64_t to double.

I finally found an ad-hoc solution (attached in Reproduce 
code area), but I wish this package will solve this overflow 

This is my first report to maintainer and I feel very 
nervous. If I have any problem, please let me know.

Best regards,

Isao Katayama

Reproduce code:
--- php_memcached.c    (revision 3366)
+++ php_memcached.c    (revision 3367)
@@ -428,7 +428,7 @@

-        ZVAL_DOUBLE(cas_token, (double)cas);
+        ZVAL_DOUBLE(cas_token, *((double *)(&cas)));


@@ -1231,7 +1231,7 @@

-    DVAL_TO_LVAL(cas_d, cas);
+    cas = *((uint64_t *)(&cas_d));

 if (i_obj->compression) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-05 07:22 UTC] nick dot madigan at baltsun dot com
This has made my day. I wish all ptsoigns were this good.
 [2012-10-27 20:39 UTC] jeremy dot belloir at gmail dot com
Thank you! You save my project.
I use Mysql Cluster & Memcached support (with ndb api) and I had the same problem.
This bug is identified (and suggested patch!) since 2 years my god...

Your patch works fine with PHP5.4.5 (latest version), PECL::Memcached-2.1.0
(latest version) [on Debian 6]
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Sep 25 05:01:23 2020 UTC