The problem was in ensuring that the list collected onto the heap was
properly preserved. The problem is that you need to create the list
on the heap, but you're doing it via a meta-operation on a choice
point that isn't at the top of the choice point stack. Originally, I
thought that setting hfreg worked for this, but a prior test broke it
during GC. (I didn't look into why.) My prior fix was simply to
comment out the line of code, as I had forgotten exactly why I'd set
hreg to hfreg. This fixed the immediate bug, but wasn't entirely
correct as its possible that if the CP changed had other choice points
on top of it, the hreg would be improperly set when those other choice
points were backtracked into. This problem could have manifested
itself in a number of ways, but heap gc caught it this time, as the
offset of the hreg for the view conssitency choice point lay outside
the heap array used when GC marks from the CP stack.
So, my fix was to run from breg to the coalesced choicepoint, setting
all of the cp_hregs to the new hreg. This is ok, as we know that the
new hreg is larger than the previous, since we just put stuff onto the
heap.