summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2023-01-16 14:43:20 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2023-01-16 14:43:20 +0000
commit438006899ec523f3aab0dd181b82753f0e3ae9ac (patch)
tree71e7f9f2180269b52c3ab41c8942797e404f464f
parentdabb650ad474a9886739606933545df7b3f699a5 (diff)
parentf999481ec2deff341edefc5d14cc2be421f4ddc3 (diff)
downloadglib-438006899ec523f3aab0dd181b82753f0e3ae9ac.tar.gz
Merge branch 'document-gtask-brokenness' into 'main'
GTask: Document issues See merge request GNOME/glib!3203
-rw-r--r--gio/gtask.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gio/gtask.c b/gio/gtask.c
index afa1b613d..80df75286 100644
--- a/gio/gtask.c
+++ b/gio/gtask.c
@@ -542,6 +542,24 @@
* having come from the `_async()` wrapper
* function (for "short-circuit" results, such as when passing
* 0 to g_input_stream_read_async()).
+ *
+ * ## Thread-safety considerations
+ *
+ * Due to some infelicities in the API design, there is a
+ * thread-safety concern that users of GTask have to be aware of:
+ *
+ * If the `main` thread drops its last reference to the source object
+ * or the task data before the task is finalized, then the finalizers
+ * of these objects may be called on the worker thread.
+ *
+ * This is a problem if the finalizers use non-threadsafe API, and
+ * can lead to hard-to-debug crashes. Possible workarounds include:
+ *
+ * - Clear task data in a signal handler for `notify::completed`
+ *
+ * - Keep iterating a main context in the main thread and defer
+ * dropping the reference to the source object to that main
+ * context when the task is finalized
*/
/**