Root safety-checking

Fixes #9117.  Thanks to Rivet and  Kyriolexical Dino for reporting.