|  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: 2021-06-09 11:25 UTC
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: cmb (profile)
Status: Closed Package: memcached (PECL)
PHP Version: 5.2.13 OS: Linux / CentOS 5.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
30 - 8 = ?
Subscribe to this entry?

 [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]
 [2021-06-09 11:25 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-06-09 11:25 UTC]
The memcached bug tracker is now on Github[1].  If this is still
an issue with the current memcached version, please report there.

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 12:01:31 2024 UTC