Checking for OBJT_DEAD in vm_object_list_handler() is racy since pagers
may set the object type to OBJT_DEAD after having dropped and reacquired
the object lock. dev_pager_dealloc() does this, for instance. Check
for the OBJ_DEAD flag as well, as that is set earlier. Fix one rare
case in the vnode pager where we freed an object without setting
OBJ_DEAD, and add an assertion to the zone destructor.
Try to minimize accesses of the object after dropping the object lock in
vm_object_list_handler().
Add a comment to warn others to think carefully before adding more
cases.
Fix shm_get_path() to reject dead objects. Fix tmpfs to finish
initialization of the object under its lock; we cannot claim that the
object is thread-private since it lives on a global list.
Try to close races with _vm_object_allocate(). Update object->flags,
which clears OBJ_DEAD, only after performing other initialization. This
is more general than the pre-existing barriers.
Clear the union fields in _vm_object_allocate(). Otherwise they can be
left set to non-zero values, and some code is not careful to reset them.
For instance, cdev_pager_allocate() inserts a new object into
dev_pager_object_list without resetting its un_pager.devp.handle field.
This also lets us check for partially constructed objects in
cdev_pager_get_path().
Fix some latent bugs after the vm_object flags field was widened from
u_short to u_int: various functions kept the old type and would silently
truncate. Only the OBJ_SYSVSHM and OBJ_POSIXSHM flags would get
truncated as a result.
Reported by: Jubal Skaggs <jubal@vcontext.net>