|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61369 shm_put_var problem
Submitted: 2012-03-13 08:56 UTC Modified: 2021-08-01 04:22 UTC
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: llongo at sata-hts dot com Assigned: cmb (profile)
Status: No Feedback Package: Semaphore related
PHP Version: Irrelevant OS: CentOS release 6.2 (Final)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-03-13 08:56 UTC] llongo at sata-hts dot com
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:
$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";
} else {
	echo "variable 2: ".$var."\n";
shm_remove($res);		// remove shared memory

Expected result:
variable 2: different short string

Actual result:
Error reading variable 2, bug!

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-13 09:03 UTC] llongo at sata-hts dot com
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.
 [2013-08-13 18:40 UTC] igor at scalr dot com
I have the same issue on CentOS 6.X. I found that with the same version of php and 
all extensions, problem exists on CentOS 6, but everything works on CentOS 5. The 
only difference is kernel version, on CentOS 6 it's 2.6.32. 

Any help on this issue would be appreciated, because shm functionality is critical 
for our application.
 [2021-07-19 11:15 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-07-19 11:15 UTC]
Is this still an issue with any of the actively supported PHP

[1] <>
 [2021-08-01 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Nov 30 09:01:25 2023 UTC