shmget problem due to *code* not shmmax/shmall

Forum for questions and support relating to the 1.25.x releases only.
Locked
BlankMan
Posts: 147
Joined: Tue Jan 19, 2010 2:53 am
Location: Milwaukee, WI USA

shmget problem due to *code* not shmmax/shmall

Post by BlankMan »

Have been getting a lot of these for a long time for different cameras:

Code: Select all

Jul 10 11:15:06 server zmc_m12[25882]: WAR [Buffer overrun at index 148, image 42398, slow down capture, speed up analysis or increase ring buffer size]
Jul 10 11:15:09 server zmc_m13[6891]: WAR [Buffer overrun at index 159, image 134407, slow down capture, speed up analysis or increase ring buffer size]
I know there's a 200 buffer limit for "Pre Event Image Count" and "Post Event Image Count", go beyond that and I do believe the mySQL insert for an event fails, would like that corrected but that's a whole 'nuther story. But that had me thinking that I couldn't go past 200 for "Image Buffer Size (frames)".

Since I don't want to slow down the capture it finally dawned on me that maybe I can go past 200 for the "Image Buffer Size (frames)" just don't use more then 200 for Pre and Post. Sure enough it worked, was able to set "Image Buffer Size (frames)" to 250 on m12 so we'll see if this "buffer overrun" stops.

But wasn't able to set m13 to 250, it was at 190, knew I couldn't go to 200, ran into that when I installed the camera so left it at 190. And it's not a shmmax/shmall issue, I'm a UNIX System Admin by day. Turns out 194 was the max, at 195 or more shmget breaks.

That magic number, 194, puts the shared memory needed for the camera at just under 2GB, 195 and you're over 2GB. Interesting... This shouldn't happen on a 64bit system. So checked the binaries to be sure they were compiled 64bit. Yep. So I dug around for maybe another system parameter that needed to be bumped up. Nope.

That left the application, ZoneMinder, so went digging through the code. Sure enough, in zm_monitor.cpp mem_size, the variable used to calculate the the shared memory needed is a signed int. That limits it to a max value of 2147483647. Sure enough 1920*1920*3*195=2156544000 so already too big before other overhead is added. Bottom line, mem_size needs to be a long.

Changed "int mem_size;" to "long mem_size;" in two spots in zm_monitor.h, recompiled, and all is well.

Hopefully this will make it into the next release.
kylejohnson
Posts: 260
Joined: Tue Aug 21, 2007 1:42 pm
Location: Baltimore, MD

Re: shmget problem due to *code* not shmmax/shmall

Post by kylejohnson »

Tracked here.
Idling as gnulnx in #zoneminder on freenode. Come say hi!
Locked