php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8985 shm_put_var wont put the given var into memory
Submitted: 2001-01-29 12:27 UTC Modified: 2002-02-15 00:00 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:5 (100.0%)
From: fuf at mobil dot cz Assigned:
Status: No Feedback Package: Semaphore related
PHP Version: 4.0.4pl1 OS: linux-2.2.18
Private report: No CVE-ID: None
 [2001-01-29 12:27 UTC] fuf at mobil dot cz
hello,

  this is the same bug as described in #7046. a call to shm_put_var() returns true all the time, but checking whether the variable has been _really_ stored reveals that it hasn't.
  this doesn't happen on my 1 cpu box (i can't reproduce it however much i try), but on a loaded server with 4 cpus it happens pretty often. of course i call sem_acquire() before writing the variable into the shared memory, so it should be safe.
  i can supply the whole source in which this happens (445 lines) but basically it's just list this:

	$semid = sem_get($sem_key, 1);
	sem_acquire($semid);
	$var = shm_get_var($shmid, $var_key); // $var is an array
	// some change to $var, $var is still an array
	shm_put_var($shmid, $var_key, $var);
	if(!is_array(shm_get_var($shmid, $var_key)))
		echo "failed to write \$var :(\n";
	sem_release($semid);

  could the problem be caused by the true multitasking on the 4 cpu server?

	thanks for any help with this,
			Michal Vitecek

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-14 02:24 UTC] lobbin@php.net
Have you tried this with 4.1.1?
 [2002-01-14 12:19 UTC] gik at zap dot cl
I've been experiencing the same problem on a dual cpu server, even with PHP 4.1.1.  Sometimes occurs that shm_put_var() doesn't correctly write data to SHM but returns true, and as I manage an array of online users in SHM, I have noticed that all users sometimes are dropped off.

I also check semaphores before writing to SHM.

16:44:41 User aaa added successfully to SHM. (8104 bytes written)
16:45:54 User bbb added successfully to SHM. (8209 bytes written)
16:47:20 User bbb deleted successfully from SHM. (8104 bytes written)
16:47:31 User ccc added successfully to SHM. (8206 bytes written)
16:49:29 User ddd added successfully to SHM. (109 bytes written)

I offer my help to debug this problem,

Giancarlo Girardi
 [2002-01-14 12:25 UTC] gik at zap dot cl
Hi!

Forgot to explain my example :)

In the Log file, "...added successfully to SHM..." means that shm_put_var() returned true.  But the next time I call shm_get_var(), I get the following error: "variable key ... doesn't exist in bbb.php4 on line ..."

Giancarlo.
 [2002-02-15 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-06-24 05:37 UTC] james at ihush dot com
I had also experienced such problem in my multi-process program, i start several processes which shared a shared memory segment created by shm_* method and when i get/set them frequently, i found some value is wrong or missing, my PHP version is 5.2.11, would you please to help me to check this problem? thank you very much ~~~~ :)
 [2010-06-24 05:38 UTC] james at ihush dot com
I can provide my code, please contact me~~
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 07:01:27 2024 UTC