This change adds a missing ref release of the previous fdtab instance on
clone, leading to a reference (and thus memory) leak with multi-fdtab.
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1617
return 0;
} else {
/* Duplicate parent's fdtab */
+ int r __maybe_unused;
+
newtab = fdtab_duplicate(tab);
if (unlikely(!newtab))
return -ENOMEM;
+ /* Compat stop-gap: release previous duplicate ref */
+ UK_ASSERT(uk_thread_uktls_var(child, active_fdtab) == tab);
+ r = uk_refcount_release(&tab->refcnt);
+ UK_ASSERT(!r); /* Cannot have been the last ref */
}
uk_thread_uktls_var(child, active_fdtab) = newtab;
return 0;