Bug #61369 [Opn]: shm_put_var problem

From: Date: Tue, 13 Mar 2012 09:03:08 +0000
Subject: Bug #61369 [Opn]: shm_put_var problem
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-168395@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61369&edit=1

 ID:                 61369
 User updated by:    llongo at sata-hts dot com
 Reported by:        llongo at sata-hts dot com
 Summary:            shm_put_var problem
 Status:             Open
 Type:               Bug
 Package:            Semaphore related
 Operating System:   CentOS release 6.2 (Final)
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

I've seen the bug with php version 5.3.3 that comes with Centos 6.2 (php-5.3.3-
3.el6_2.6.x86_64). With the same version of php in Centos 5.7 (php53-5.3.3-
1.el5_7.6) the test script works in the right way.


Previous Comments:
------------------------------------------------------------------------
[2012-03-13 08:56:37] llongo at sata-hts dot com

Description:
------------
There is a problem with shm_put_var: when you call shm_put_var with a "long" 
string as value (100 chars at least) in a shared memory area with some variables 
already created, after updating the other variables with successive calls to 
shm_put_var, this variables become non-existent and you cannot get their values 
with shm_get_var.

Test script:
---------------
<?php
$key = 1000;
$test1 = "short string";
$test2 = "long string with at least 100 characters
abcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvz";
$test3 = "different short string";
$res = shm_attach($key);	// attach to shared memory
if (false === shm_put_var ($res,1,$test1)) {		// write var 1
	echo "unable to put var 1 with ".$test1."\n";
}
if (false === shm_put_var ($res,2,$test1)) {		// write var 2
	echo "unable to put var 2 with ".$test1."\n";
}
if (false === shm_put_var ($res,3,$test2)) {		// write var 3
	echo "unable to put var 3 with ".$test2."\n";
}
if (false === shm_put_var ($res,2,$test3)) {		// write again var 2 => after this put var, var 2
and 3 disappear... bug?
	echo "unable to put var 2 with ".$test1."\n";
}
if (false === ($var = shm_get_var ($res,2))) {		// get var 2
	echo "Error reading variable 2, bug!\n";
	var_dump($var);
} else {
	echo "variable 2: ".$var."\n";
}
shm_remove($res);		// remove shared memory
shm_detach($res);
exit;
?>

Expected result:
----------------
variable 2: different short string

Actual result:
--------------
Error reading variable 2, bug!
bool(false)

And php warning:
PHP Warning:  shm_get_var(): variable key 2 doesn't exist in 
/root/test_bug_shm.php on line 19


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61369&edit=1


Thread (5 messages)

« previous php.bugs (#168395) next »