Bugs 2817008, 2826367

Brent, have you looked at either 2817008 or 2826367? I can’t replicate
either of them, but I’ve had a go at trying to understand the code involved.

What I see is that

contents[index] = p

throws because index is too large, and that’s passed through
Stack.insertChild() from Stack.setState(). I don’t understand
Stack.setState(). It looks to me like insertChild() is be called with
index = 0, but that conflicts with the exception saying that index = 10, in
the case of Bug 2826367. That points to pieceCount being altered as a side
effect of something between when it’s set to 0 and when it’s passed to
insertChild() as an argument, but I don’t see how that’s happening.