<div dir="ltr"><div style="font-size:12.8px">Hi folks,</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I'm experiencing an issue wherein a temporary load spike on a system causes shmsink to stop delivering frames permanently.</div><div style="font-size:12.8px">(a cron job is doing it to me in real life, but I can replicate the issue with "stress -m 5 -t 5")</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">My pipeline is decklinkvideosrc ! videoconvert ! shmsink    -> snowmix</div><div style="font-size:12.8px"><span style="font-size:12.8px">(the issue can be duplicated using filesrc location=test.mp4 ! decodebin in place of the decklinkvideosrc)</span><br></div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px">more precicely:</div><div style="font-size:12.8px">gst-launch-1.0 -v decklinkvideosrc mode=19 connection=sdi device-number=0 name=decoder ! videorate ! videoscale ! videoconvert ! video/x-raw, format=\(string\)BGRA, pixel-aspect-ratio=\(fraction\<wbr>)1/1, interlace-mode=\(string\)<wbr>progressive, width=\(int\)1280, height=\(int\)720, framerate=\(fraction\)30/1 ! queue leaky=2 ! shmsink socket-path=/tmp/feed1-<wbr>control-pipe shm-size=100000000 wait-for-connection=0 sync=false<br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">So, my shm size is roughly 27 frames.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">It appears that during the load spike frames pile up in the shm space.</div><div style="font-size:12.8px">When load returns to normal, the shm client reads and ACKs every one of the backlogged buffers, but they do not seem to be properly freed in the shmsink.</div><div style="font-size:12.8px">If everything recovers before the shm space is filled (say, 25 frames have accumulated in the ShmAllocSpace) then everything seems to recover fine, frames flow normally.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">But if shmsink ever fills the ShmAllocSpace then I'm boned.  the client will, when it recovers, read all the buffers that are in there, but no more will ever be written.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br>When it ends up in this state, this function:  shm_alloc_space_alloc_block   in shmalloc.c  is being called for each new frame and is returning NULL.<br></div><div style="font-size:12.8px">When this is happening, the ShmAllocSpace linked list of blocks has 27 entries.   It stays at 27 forever.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I watched  sp_writer_recv  in shmpipe.c  and I can see an ACK come in for every one of those 27 buffers.  The ShmPipe's linked list of buffers get decremented from 27 down to a normal level, but the ShmAllocSpace's list of blocks never goes down.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I tried to understand how blocks in the ShmAllocSpace get released or re-used but I'm failing to wrap my head around it.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Any thoughts would be welcome.</div><div style="font-size:12.8px">For the moment I can just throw a huge shm-size at the problem (300 frames?) and hope I never have a load issue that lasts that long.</div><div style="font-size:12.8px">That works but isn't a very satisfying solution.</div></div>