Skip to content

wp: invalidate WpGlobal id when removed from registry

P V requested to merge pvir/wireplumber:global-add-rm-add into master

Once an object is removed from the registry, its id is invalidated and can be later reused by other objects. WpGlobal objects may be long-lived: e.g. those in tmp_globals may live over an add,remove,add sequence for the same id, and a new WpGlobal must be used for the second add. However, currently e.g. wp_registry_prepare_new_global may pick the WpGlobal for a previously removed object from the tmp_globals list.

To address this, invalidate the WpGlobal id immediately when we get the registry remove event.


I don't actually have a test case that reproduces a problem here right now, but reading the code it seems that if you get the sequence "add,remove,add" of registry events for the same ID before the sync event, then the second "add" will reuse the WpGlobal of the first "add", which corresponds to a completely different object and you can get problems.

XXX: I'd need to read more carefully through the Wp sources to understand how the object lifetimes in Wp actually are supposed to work, but maybe those more familiar with Wp can already say how this should be done.

Edited by George Kiagiadakis

Merge request reports