bufferpool: in renegotation, bufferpool can be given to element while another one still uses it
@thiagossantos
Submitted by Thiago Sousa Santos Link to original bug (#748344)
Description
Suppose the following pipeline:
source ! filter ! sink
Initially it works in passthrough mode so source gets a bufferpool from sink and uses it.
At some point when filter gets a buffer it decides it can't do passthrough anymore (the user might have set a property to it, for example).
Filter will request a bufferpool from sink. If the caps in the request are the same as source have been using the sink might return the same bufferpool. It sets the bufferpool to active (it already was active) and will use it to push a buffer. In this process filter also sent a reconfigure upstream to make source realize it isn't in passthrough anymore and that it should request a new bufferpool.
At the next source loop it will do the reconfigure and as part of the acquisition of a new bufferpool, set the old one to inactive.
Now filter receives the new buffer from source and tries to get a buffer from the pool to use. This same pool has been stopped by source in its renegotiation and filter will fail because its pool is now unexpectedly flushing.
Adding queues to the pipeline can make this racy as well.
I have an unfinished work that triggers this issue and I'll try to make it into an application so others can easily reproduce it. (Likely uploading it tomorrow)