Skip to content

mem: track fd invalidation of imported memblocks

P V requested to merge pvir/pipewire:memblock-inval into master

When a memblock closes its fd, have it emit signal to other memblocks possibly sharing the fd, so they know it is now invalid.

When a memblock has an invalidated fd, it'll not allow mapping more memory, nor match against fd searches.

This avoids bugs where kernel fd reuse causes already invalid memblocks to be used. Generally, higher level code should make sure memblocks get freed in right order so that this situation does not occur, but try to keep mempool in consistent state regardless.


See #3825 (comment 2266814)

This seems to fix the symptoms in #3825, as it removes one way for the mempool state to get confused.

However, it's probably still a bug that the higher level frees a memblock while the fd has been imported to another pool. Still, I think it's useful to have the mempool be more robust, as bugs like in #3825 are a bit hard to debug.

@pobrn's extra validation #3825 (comment 2265190) (but skipping the invalidated memblocks) also doesn't seem to trip with this.

Edited by P V

Merge request reports