fix a (rare and testing-only) data race