Add an opportunistic thread-safety fix

It turns out that g_object_weak_ref() isn’t thread safe, and threaded
applications doing lots of concurrent object references/dereferences
across multiple threads can miss out _object_finalized() calls, which
effectively part-corrupts the objects table, and can cause crashes when
printing it out.

See: https://bugzilla.gnome.org/show_bug.cgi?id=548954

This fix tries to avoid some of those crashes, but can’t avoid all of
them, since it only detects really obviously corrupt entries in the
table.

More importantly, it includes a comment which describes the potential
long-term fixes, none of which I have time to implement at the moment.