-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v4l2_req_media: race condition between destroying media_pool
and returning media_request
to it
#78
Comments
Thanks - I'll look into that. I do run valgrind over that code code but obviously my test setup missed that. |
I think I see the problem - it is, I think, a locking fail on delete where the req chain can become broken, but this doesn't happen for me by default - can you give me whatever stream you are using to test with including the appropriate command line so I can check that (a) I can reproduce the fail and (b) I've fixed it. Ta |
The command I used is:
Where the I'm not sure what you mean by "a locking fail", but if you're talking about locking in |
This prevents media_pool from being freed before all requests are returned to it. Fixes: jc-kynesim#78
It seems to be possible that
media_pool
is destroyed before allmedia_request
are returned to it. When a remainingmedia_request
is returned withmedia_request_done()
, the use-after-free occurs onmedia_pool
, and thatmedia_request
is also leaked since no one will free it.This is the output from Valgrind which lead to this discovery. The exact commit used is 61733f1 ("v4l2: Add (more) RGB formats to DRM & V4L2") on branch
dev/6.0/rpi_import_1
: https://paste.ubuntu.com/p/GBwwSPVrbp/Inspired by how Gstreamer do it, I think the solution is to make
media_pool
ref-counted, then makemedia_request_get()
increase the refcount andmedia_request_done()
decrease it. This makes sure thatmedia_pool
outlive themedia_request
.The text was updated successfully, but these errors were encountered: