From dc197cd7f30bff718ea06fe6978c9ce203a40dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 27 Oct 2024 12:58:08 +0200 Subject: [PATCH] arcbox: Document that implementing weak references via the clear_func is not safe --- glib/garcbox.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/glib/garcbox.c b/glib/garcbox.c index da19cd405..400280c04 100644 --- a/glib/garcbox.c +++ b/glib/garcbox.c @@ -207,6 +207,11 @@ g_atomic_rc_box_release (gpointer mem_block) * to clear the contents of @mem_block, and then will free the * resources allocated for @mem_block. * + * Note that implementing weak references via @clear_func is not thread-safe: + * clearing a pointer to the memory from the callback can race with another + * thread trying to access it as @mem_block already has a reference count of 0 + * when the callback is called and will be freed. + * * Since: 2.58 */ void