Reapply r140979 with fix! We never did get a testcase, but careful review of the