[Bug 796692] buffer: Merging memories while mapping is unsafe for non-writable buffers

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Thu Jun 28 08:48:46 UTC 2018


https://bugzilla.gnome.org/show_bug.cgi?id=796692

Sebastian Dröge (slomo) <slomo at coaxion.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|buffer:                     |buffer: Merging memories
                   |gst_buffer_peek_memory() is |while mapping is unsafe for
                   |inherently unsafe           |non-writable buffers

--- Comment #2 from Sebastian Dröge (slomo) <slomo at coaxion.net> ---
It's actually much worse than that. Consider the following case: Thread A
merges the memories of a buffer while mapping it completely, thread B iterates
over all memories to do things with them separately. While iterating in B,
thread A can finish, replace all memories and from that point onwards thread B
will assert/crash/etc because there are no N memories anymore in the buffer.

The only safe solution to this seems to be to never replace the memories in
buffers if they are not writable, and instead only store the merged memory in
the GstMapInfo (plus a flag to unref it on unmap). This will mean that merging
would happen every single time for such buffers, and even at the same time in
multiple threads if we're unlucky. But at least it would be safe :)

Comments?

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list