ostreedev / ostree

Operating system and container binary deployment and upgrades
https://ostreedev.github.io/ostree/
Other
1.31k stars 300 forks source link

curl: Make socket callback during cleanup into no-op #3307

Closed cgwalters closed 2 months ago

cgwalters commented 2 months ago

Because curl_multi_cleanup may invoke callbacks, we effectively have some circular references going on here. See discussion in

https://github.com/curl/curl/issues/14860

Basically what we do is the socket callback libcurl may invoke into a no-op when we detect we're finalizing. The data structures are owned by this object and not by the callbacks, and will be destroyed below. Note that e.g. g_hash_table_unref() may itself invoke callbacks, which is where some data is cleaned up.

Signed-off-by: Colin Walters walters@verbum.org

Closes: https://github.com/ostreedev/ostree/issues/3299


cgwalters commented 2 months ago

For people who are distributing ostree: in my opinion this patch is quite safe to cherry pick. The affected code here is during the teardown path and we're just making a called function into a no-op, so realistically the worst case is memory leaks. But for leaks: ASAN is still happy with this change, and from my auditing of the code again we're always relying on our own teardown, not on the libcurl socket callback.