php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45360 Variable copies corrupted by memcache problem
Submitted: 2008-06-25 20:24 UTC Modified: 2008-07-02 17:21 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: richc at drivecurrent dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.2.6 OS: Linux Redhat
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: richc at drivecurrent dot com
New email:
PHP Version: OS:

 

 [2008-06-25 20:24 UTC] richc at drivecurrent dot com
Description:
------------
I believe a problem with memcache reveals a problem with PHP. (PECL Memcache bug: http://pecl.php.net/bugs/bug.php?id=14239)

A call to memcache changes the parameter variable to 'string' type. The PHP problem is that this conversion is passed to ancestor and decendent copies of the variable, even through function calls, even though passed by value, not reference.

This appears to be similar to PHP Bug #42813, closed as Bogus. This is a newly compiled PHP installation using latest PHP, PECL, memcached.

Reproduce code:
---------------
$value1 = 1.2;
$value2 = $value1; // this value is being passed -- all get modified
$value3 = $value2;

echo '<br>1 ' . gettype($value1) . ' / ' . gettype($value2) . ' / ' . gettype($value3);
set('asdf', $value2);
echo '<br>4 ' . gettype($value1) . ' / ' . gettype($value2) . ' / ' . gettype($value3);

function set( $key, $valueA ) {
  $valueB = $valueA; // this value is being passed -- all get modified
  $valueC = $valueB;
  
  echo '<br>2 ' . gettype($valueA) . ' / ' . gettype($valueB) . ' / ' . gettype($valueC);
  
  $m = new Memcache();
  $m->addServer('localhost');
  $m->set($key, $valueB);
  
  echo '<br>3 ' . gettype($valueA) . ' / ' . gettype($valueB) . ' / ' . gettype($valueC);
}

Expected result:
----------------
Even when memcache bug corrupts $valueB, others should not be affected:

1 double / double / double
2 double / double / double
3 double / string / double
4 double / string / double

Actual result:
--------------
1 double / double / double
2 double / double / double
3 string / string / string
4 string / string / string

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-25 20:32 UTC] richc at drivecurrent dot com
The last "Expected Result" should read
  4 double / double / double
 [2008-07-02 11:50 UTC] jani@php.net
Memcache bugs are not PHP bugs -> bogus.
 [2008-07-02 17:21 UTC] richc at drivecurrent dot com
** Could someone please take a look at this bug instead of closing as bogus. This is NOT simply a memcache bug unless PHP allows memcache to corrupt variables outside its context--which still makes it a PHP bug. This is a PHP bug revealed by the memcache bug. Please take another look.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 22:01:31 2024 UTC