OK for whatever it is worth and for my peace of mind I found the Bug and fixed it.
There was another bug in InvalidateCache.
I was not cleaning the Muti Resolution Broad Phase.
I short this is what Happened, In Newton what you add a body to the world, the body is added to the top grid of the broadPhase, Then during the update bodies a place to the grid that the belong.
Your test was a god test because in exposed the problem.
When you added the bodies for the first time they were in the top grid, the solver start moving the around as the simulation progresses.
The when you cal invalidate, bodies and the contacts are all cleaned up, but the Broad Phase was not,
That should not be a problem because the next update should place then in the correct Cell, and in fact is does do that, but here is the problems, the first time it place the bodies for the root cell to the cell the belong, but the second time in move the form various cells to the cell that the belong.
To make clearer let us label the bodies
A, B, C, B and they are all in the Top cell say Cell 0
After the first update let say the scene is organizes
A, B in Cell 15, C in Cell 100, and D in Cell 101
The second Update body B moves to 100 and we get
A in Cell 15, B, C in Cell 100, and D in Cell 101
Now we want to rest the Scene by calling Invalidate Cache,
And we run a new Update
Now the scene start form where the Last update ended, which is
A in Cell 15, B, C in Cell 100, and D in Cell 101
The first update find that body B belong to cell 15, so in moves body B to cell 15,
But since body a and B have the same position it gets
B, A in Cell 15, C in Cell 100, and D in Cell 101
Instead of Getting
A, B in Cell 15, C in Cell 100, and D in Cell 101
And that lead to a generation of the same colliding pairs but in different order.
In the first pass the pair will be, AB, AC, BC, …
While in the second pass they will be BA, BC, AC…
I fixed quite simple, basically I remove all the bodies from the world and re-insert then again, which causes then to go to the top cell, then update will guarantee to move the bodies from the same origin.
Anyway the bug is fixed and if you still want to use Newton you can download 2.04 them it should work fine now.
Here is the summary of you test
start 0
>>> 0
Hash: 0 00000000
end 0
>>> 0
Hash: 31432400 01df9ed0
--------------------------------------------
start 1
>>> 0
Hash: 0 00000000
end 1
Hash: 31432400 01df9ed0