Page 1 of 1

Shared memory ownership problem

Posted: Fri Jan 18, 2008 1:41 am
by jacomoman
Hi,

I'm running ZM v1.22.3 on Centos 5 (2.6.9-34.ELsmp). For a long time now (can't recall exactly how long) every time I either start or re-start ZM (via the web UI) my monitor 1 fails to start with this message in zmwatch.log:

Code: Select all

01/17/08 12:54:07.060343 zmwatch[15938].INF ['zmc -m 1' starting at 08/01/17 12:54:07, pid = 16452]
01/17/08 12:54:08.064372 zmwatch[15938].ERR [Can't read 'shared_data:size' from shared memory '7a6d2001/622595': Permission denied]
01/17/08 12:54:08.064664 zmwatch[15938].INF [Restarting capture daemon for Hallway-Cam, shared memory not valid]
I'd seen a msg on the forum where someone had suggested that somehow one of the shared-mem segments that are supposed to be owned by the process that runs ZM (apache on my machine) gets owned by root and ZM can't read it and you get this error. Doing a "ipcs -m" I see exactly that:

Code: Select all

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000001 32768      root      600        655360     2
0x00000000 163842     gdm       600        393216     2          dest
0x7a6d2001 393217     root      600        36865188   2    <---------- the problem segment owned by root
0x7a6d2002 196611     apache    700        9217188    1
0x7a6d2004 229380     apache    700        36865188   2
0x7a6d200b 262149     apache    700        36865188   2
0x7a6d2007 294918     apache    700        36865188   2
0x7a6d200a 327687     apache    700        36865188   2
Of course, all I have to do is "ipcrm -M 0x7a6d2001" to remove it and a few seconds later the apache user takes over that shmem seg and my monitor starts working again, but it's still a very manual operation and just a hassel. So I still have this question: Why does this happen? Did I set something up wrong to cause ZM to do this on every start/restart?

For info, my shmem setup looks like this:

Code: Select all

ipcs -l

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 1024000
max total shared memory (kbytes) = 1024000
min seg size (bytes) = 1

------ Semaphore Limits --------
max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32
semaphore max value = 32767

------ Messages: Limits --------
max queues system wide = 16
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384

Posted: Tue Jan 22, 2008 9:50 pm
by zoneminder
What parameters did you pass to configure?

Also, what are you using to start ZM on system start?

Posted: Wed Jan 23, 2008 4:51 pm
by jacomoman
Very simple configure cmd line:

Code: Select all

./configure --with-webdir=/var/www/zm --with-cgidir=/var/www/cgi-bin
And I haven't set up ZM to start automatically, mostly due to this problem since every time it starts root owns that one shmem seg and I have to manually "unstick" it every time. As of right now if I reboot/restart my machine I just get back into the UI and start from there. Then of course afterwards I have to run that command to remove the shmem seg owned by root.

Thanks for your reply and any light you can shed on this. It's really a pain. :(

Jac

Posted: Wed Jan 23, 2008 7:52 pm
by cordel
You didn't define a webuser and webgroup in your ./configure, so did you set the proper web usr/group in zm.conf as detailed in the Documentation?
Also you not starting ZM with the root user are you?

Posted: Mon Jan 28, 2008 11:08 pm
by jacomoman
No, didn't specify those on the ./configure line but here's what's in my zm.conf, must have been defaulted by the configure script itself:

Code: Select all

# Username and group that web daemon (httpd/apache) runs as
ZM_WEB_USER=apache
ZM_WEB_GROUP=apache
Also I've verified this in "top" since all ZM-related processes run as apache (zma, zmc, etc.)

And no, I never start ZM as the root user. I always start/stop ZM from its own web UI. So whatever that PHP code is doing is what's happening. As I'd mentioned earlier, I don't start ZM automatically. Onlyl through the web UI.

Posted: Tue Apr 08, 2008 8:54 pm
by jacomoman
I know it's been a while since I posted this, but does anyone have any idea what the cause of this issue might be?

It's still occurring and I sure would like to know why.

Thanks,

-Jac

Posted: Tue Apr 08, 2008 9:07 pm
by cordel
I'm certainly not sure what would cause just the first segment to be owned by root.
I have done many Cent5 installs and never incountered this problem. :?

Like yours: shm related problems

Posted: Sat Nov 08, 2008 3:42 am
by Anyeos
I have problems like you with shm, here the log:

11/08/08 03:57:38.784484 zmwatch[10395].ERR [Can't get shared memory id '7a6d0002', 2: No such file or directory]
11/08/08 03:57:38.784949 zmwatch[10395].INF [Restarting capture daemon for Entradas, shared memory not valid]
11/08/08 03:57:39.324205 zmwatch[10395].INF ['zmc -d /dev/video0' starting at 08/11/08 03:57:39, pid = 11299]

famelix:/etc/apt# ipcs -m

---- Segmentos memoria compartida ----
key shmid propietario perms bytes nattch estado
0x00500002 0 root 700 36865188 0
0x7a6d0002 1769473 www-data 700 36865188 0
0x00000000 786435 famelix 600 393216 2 dest
0x00000000 819204 famelix 600 393216 2 dest

I don't understand why it have that problems related with shm.

No such file or directory??
Permission Denied??

Did ZM really know how to handle shm?

Ok, i will let you get the answer.
bye :P

Video Capture Card Related

Posted: Sat Nov 08, 2008 4:02 am
by Anyeos
Hey guys, the problem is too related with the video capture card. If zmc cannot get video from the capture card then does not allocate the shm. And you only will be noticed about the non existence of the shm.
I just was testing the capture card with xawtv (just the video cable was not working good) and checked it. Now ZoneMinder too works.

That was all what I did: checking the videocable using xawtv. That maybe solve your problem too.

Bye