Assert in trunk "b2TimeOfImpact.cpp" (Line 441)

I have been using the trunk (rev#220) test-bed and occasionally under a RELEASE build I get the test-bed "locking". This always seems to happen when using the "Pyramid" level and has happened on two different computers on different OSs etc. It happens a few times a day and is hard to reproduce and I generally just throw objects here and there. The only change I have made is to activate sleeping in the test-bed (off by default) and have increased the number of proxies to 4096 although I have not modified the tests in any way. I modified the proxies as I'm just testing the memory allocation and general performance of increasing the potential proxy count etc.

I tried reproducing this under a DEBUG build and only once found it asserted in "b2TimeOfImpact" (line 441) - "b2Assert(rootIterCount < 50)" which is in the middle of a "for(;;)" which may be why there's an apparent lock as it's never getting out of the loop.

I have tried reverting the number of proxies back to 512 to see if that is related somehow but so far today have not seen the lock. I will continue to try that though.

Any clues as to what might be happening here? It's the only problem of significance (to me) I can see in the trunk right now.
I changed the time of impact code to a new algorithm recently. Obviously some bugs remain. Unfortunately I cannot find the cause of the endless iterations from your report.

Anyhow, you should change the line with the assertion to:
Code:
if (rootIterCount == 50)
{
    break;
}
I'm not sure how important this is to you (Erin) as you are in the progress of rewriting a lot of implementations.
We (Farseer Physics Engine team) have ported revision 220 to C# and I've also seen this assert fire quite some times. I mainly get it in the elastic bodies sample. It usually takes the elastic body some time before it happens, so be patient.
Thanks Erin, I'll put that break in. I will agree that duplicating this problem is very hard indeed. The worst kind of problem!

Thanks again.
@Erin: In-case it helps, I have noticed that if I just sit and watch the "Elastic Body" test it happens after the body has been around a few times. This is with an unmodified trunk build.

EDIT: Forgot to say that the code modification you suggested obviously stops the assert but because the condition seems to last for a significant period of time, it ends up with the simulation stalling and the subsequent frame-rate plummeting. I have found that I can reproduce this failure in the "Elastic Body" test consistently across several machines.

I hope this helps. If there's anything I can do to help further, including any trace information then please just ask.
Not sure if this is helpful either but I noticed a debug section prior to the TOI analysis iteration loop so I placed that inside the loop when the iteration count got to 50.

I noticed the curve goes negative but I have no idea what it represents. I wish I understood the code further.

Anyway, I got the following results:

Code:
0 0.005
0.01 0.00450366
0.02 0.00427095
0.03 0.00377471
0.04 0.00327852
0.05 0.00304973
0.06 0.00255364
0.07 0.00232109
0.08 0.0018251
0.09 0.00133297
0.1 0.00109672
0.11 0.000604693
0.12 0.000105087
0.13 -0.000123422
0.14 -0.000619119
0.15 -0.000847563
0.16 -0.00134316
0.17 -0.00184252
0.18 -0.00206704
0.19 -0.0025625
0.2 -0.00306171
0.21 -0.00329374
0.22 -0.00378523
0.23 -0.00401721
0.24 -0.0045086
0.25 -0.00500756
0.26 -0.00523561
0.27 -0.00573448
0.28 -0.00622949
0.29 -0.00645743
0.3 -0.00695615
0.31 -0.007451
0.32 -0.00767883
0.33 -0.00817359
0.34 -0.00840135
0.35 -0.00889602
0.36 -0.00939063
0.37 -0.0096221
0.38 -0.0101166
0.39 -0.0106149
0.4 -0.0108386
0.41 -0.0113368
0.42 -0.0115643
0.43 -0.0120585
0.44 -0.0125528
0.45 -0.0127801
0.46 -0.0132781
0.47 -0.0137683
0.48 -0.0139994
0.49 -0.0144934
0.5 -0.0147244
0.51 -0.0152144
0.52 -0.015712
0.53 -0.0159391
0.54 -0.0164329
0.55 -0.0169265
0.56 -0.0171535
0.57 -0.0176471
0.58 -0.0181406
0.59 -0.0183675
0.6 -0.0188647
0.61 -0.0190915
0.62 -0.0195887
0.63 -0.0200819
0.64 -0.0203086
0.65 -0.0208018
0.66 -0.0212949
0.67 -0.0215215
0.68 -0.0220145
0.69 -0.0222411
0.7 -0.0227378
0.71 -0.0232307
0.72 -0.0234571
0.73 -0.0239499
0.74 -0.0244464
0.75 -0.0246727
0.76 -0.0251654
0.77 -0.0256618
0.78 -0.025888
0.79 -0.0263804
0.8 -0.0266066
0.81 -0.0271028
0.82 -0.0275951
0.83 -0.0278211
0.839999 -0.0283095
0.849999 -0.0288055
0.859999 -0.0290314
0.869999 -0.0295235
0.879999 -0.0297532
0.889999 -0.0302452
0.899999 -0.0307371
0.909999 -0.0309629
0.919999 -0.0314585
0.929999 -0.0319503
0.939999 -0.0321759
0.949999 -0.0326676
0.959999 -0.032897
0.969999 -0.0333848
0.979999 -0.0338763
0.989999 -0.0341018
0.999999 -0.034597
That is interesting. The line is a bit wobbly for some reason.

I will be making some changes soon to make this easier to diagnose.
Sounds good Erin. Post back here if there's anything I can do to help further.

Original thread: https://box2d.org/forum/viewtopic.php?t=3443