GNOME Bugzilla – Bug 791787
rare failure in gdbus-peer test: invalid uninstantiatable type '(null)' in cast to 'GDBusServer'
Last modified: 2018-05-24 20:06:11 UTC
+ Trace 238273
Thread 1 (Thread 0x7fe93db8b700 (LWP 15920))
To reproduce, run the gdbus-peer test in a loop (this is rare, it took me 1583 attempts). Possibly related to Bug #701105. Complete backtrace (all threads): (gdb) thread apply all bt
+ Trace 238274
I suspect this is because on_run() can be run in any thread. 1. GDBusServer.on_run() gets called in a new worker thread 2. GDBusServer.finalize() gets called in another thread (the worker thread doesn’t have a reference to the GDBusServer) 3. GDBusServer.finalize() completes and disconnects on_run() (but that’s too late) 4. GDBusServer.on_run() resumes and finds that its @server is garbage The fix is probably going to end up being a global hash table of GDBusServer instances, since we can’t allocate any per-GDBusServer locks or weak refs, since there’d be no safe place to free them afterwards.
(In reply to Philip Withnall from comment #2) > The fix is probably going to end up being a global hash table of GDBusServer > instances, since we can’t allocate any per-GDBusServer locks or weak refs, > since there’d be no safe place to free them afterwards. I would hope we can do better than that, but I'm not sure how. Maybe on_run could have a GWeakRef<GDBusServer> as its user-data and convert it to a strong ref for the duration? GWeakRef is meant to be thread-safe.
(In reply to Simon McVittie from comment #3) > (In reply to Philip Withnall from comment #2) > > The fix is probably going to end up being a global hash table of GDBusServer > > instances, since we can’t allocate any per-GDBusServer locks or weak refs, > > since there’d be no safe place to free them afterwards. > > I would hope we can do better than that, but I'm not sure how. > > Maybe on_run could have a GWeakRef<GDBusServer> as its user-data and convert > it to a strong ref for the duration? GWeakRef is meant to be thread-safe. I already played around with that earlier this morning and couldn’t work out how to safely free the GWeakRef afterwards — you end up freeing it after it first returns NULL, but that’s not safe if there are multiple on_run() calls in flight in different worker threads.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/1318.