Skip to content

Commit

Permalink
arcbox: Document that implementing weak references via the clear_func…
Browse files Browse the repository at this point in the history
… is not safe
  • Loading branch information
sdroege committed Nov 8, 2024
1 parent 0828714 commit dc197cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions glib/garcbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc197cd

Please sign in to comment.