fix allocation bug in `equal?` on deeply nested values

Based on the core file, this bug seems likely responsible for the
`raco setup` crash on DrDr for push 29346.

Merge to v6.1.1