[Bug 40370] Merge r351504 to the 8.0 branch

Eli Friedman changed bug 40370