From:
Operating system: CentOS release 6.2 (Final)
PHP version: Irrelevant
Package: Semaphore related
Bug Type: Bug
Bug description:shm_put_var problem
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 bug report at https://bugs.php.net/bug.php?id=61369&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=61369&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=61369&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=61369&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=61369&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=61369&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=61369&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=61369&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=61369&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=61369&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=61369&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=61369&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=61369&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=61369&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=61369&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=61369&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61369&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=61369&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=61369&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=61369&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=61369&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=61369&r=mysqlcfg