Jdesk / memcached

Automatically exported from code.google.com/p/memcached
0 stars 0 forks source link

Unable to decr a key with value greater than 2^63 #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Steps to reproduce:
weirdan@virtual-debian:/home/sam/trunk/test/unit$ echo $((2**63-1))
9223372036854775807
weirdan@virtual-debian:/home/sam/trunk/test/unit$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
stats
STAT pid 590
STAT uptime 84394
STAT time 1235062054
STAT version 1.2.6
STAT pointer_size 32
STAT rusage_user 0.220013
STAT rusage_system 3.184199
STAT curr_items 683
STAT total_items 7293
STAT bytes 293187
STAT curr_connections 6
STAT total_connections 503
STAT connection_structures 16
STAT cmd_get 15597
STAT cmd_set 7291
STAT get_hits 8319
STAT get_misses 7278
STAT evictions 0
STAT bytes_read 7525934
STAT bytes_written 7270772
STAT limit_maxbytes 67108864
STAT threads 1
END
set aaa 0 0 19
9223372036854775807
STORED
get aaa
VALUE aaa 0 19
9223372036854775807
END
incr aaa 1
9223372036854775808
incr aaa 1
9223372036854775809
decr aaa 1
0
quit
Connection closed by foreign host.
weirdan@virtual-debian:/home/sam/trunk/test/unit$

Expected output:
decr should return 9223372036854775808

Memcache Version 1.2.6, running on debian linux 32bit, compiled with:
weirdan@virtual-debian:/home/sam/trunk/test/unit$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.3-3' --
with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-
languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-
system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-
threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --
program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-
objc-gc --enable-mpfr --enable-targets=all --enable-cld --with-tune=generic 
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --
target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Debian 4.3.3-3)

The reason for this problem seems to be on this line: 
http://consoleninja.net/gitweb/gitweb.cgi?
p=memcached.git;a=blob;f=memcached.c;h=3b7a187f726d4eb6ca5ae9684a3edaca984f
e58b;hb=HEAD#l1580

1580         if (delta >= value) value = 0;

where signed long long int delta is compared to unsigned long long value.

Original issue reported on code.google.com by weirdan on 19 Feb 2009 at 4:56

GoogleCodeExporter commented 9 years ago
I'll write a test for this for both protocols.

Original comment by dsalli...@gmail.com on 26 Feb 2009 at 5:39

GoogleCodeExporter commented 9 years ago
Wrote tests for both protocols and a fix.

013e17cc7487d3d24c7f6b30c206bd6421ed6f6d

Original comment by dsalli...@gmail.com on 26 Feb 2009 at 5:35