php.net |  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: -
Votes:2
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: isao dot kata at gmail dot com
New email:
PHP Version: OS:

 

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

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.

http://github.com/etolabo/kumofs

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

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

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 
problem.

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_dtor(cas_token);
-        ZVAL_DOUBLE(cas_token, (double)cas);
+        ZVAL_DOUBLE(cas_token, *((double *)(&cas)));

 memcached_result_free(&result);

@@ -1231,7 +1231,7 @@
 RETURN_FALSE;
 }

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

 if (i_obj->compression) {
 flags |= MEMC_VAL_COMPRESSED;


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 00:01:31 2019 UTC