Skip Menu |

This queue is for tickets about the Cache-Memcached-Fast CPAN distribution.

Report information
The Basics
Id: 65381
Status: open
Priority: 0/
Queue: Cache-Memcached-Fast

People
Owner: Nobody in particular
Requestors: JGOLDBERG [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.19
Fixed in: (no value)



Subject: cas value not being converted to perl correctly on 32bit system
When retrieving the cas value on a 32 bit machine, the value is being incorrectly converted to a perl uv. Attached is a patch to convert it to a perl string after a gets() and then back to a long long when calling cas(). Thank you for your work on this module!
Subject: Fast.xs.patch
--- Cache-Memcached-Fast-0.19/Fast.xs 2010-04-24 03:25:15.000000000 -0700 +++ /home/jgoldberg/Cache-Memcached-Fast-0.19/Fast.xs 2011-02-01 14:15:31.965175000 -0800 @@ -562,8 +562,10 @@ else { AV *cas_val = newAV(); + char mybuf[21]; + sprintf(mybuf,"%llu",m->cas); av_extend(cas_val, 1); - av_push(cas_val, newSVuv(m->cas)); + av_push(cas_val, newSVpv(mybuf,0)); av_push(cas_val, value_sv); value_res->vals = newRV_noinc((SV *) cas_val); } @@ -592,8 +594,10 @@ else { AV *cas_val = newAV(); + char mybuf[21]; + sprintf(mybuf,"%llu",m->cas); av_extend(cas_val, 1); - av_push(cas_val, newSVuv(m->cas)); + av_push(cas_val, newSVpv(mybuf,0)); av_push(cas_val, value_sv); av_store((AV *) value_res->vals, key_index, newRV_noinc((SV *) cas_val)); } @@ -718,7 +722,7 @@ ++arg; if (ix == CMD_CAS) { - cas = SvUV(ST(arg)); + cas = atoll(SvPV_nolen(ST(arg))); ++arg; } sv = ST(arg); @@ -807,7 +811,7 @@ ++arg; if (ix == CMD_CAS) { - cas = SvUV(*av_fetch(av, arg, 0)); + cas = atoll(SvPV_nolen(*av_fetch(av, arg, 0))); ++arg; } sv = *av_fetch(av, arg, 0);
On Wed Feb 02 15:05:27 2011, JGOLDBERG wrote: Show quoted text
> Attached is a patch to convert it to a perl string after a > gets() and then back to a long long when calling cas().
Thanks for the report, looks valid. Patch is also good (would be perfect if test case is also included). However, since the original conversion to SvUV is wrong, this is kinda strange now that we get CAS value over text protocol, then convert it to an integer, then again to string. Shouldn't the fix be just to pass CAS as a string to Perl, without intermediate ull representation? This would also have an advantage that CAS would become completely opaque. I really appreciate if you work on such version of the fix :).