Assertion failed m_contactCount < m_contactCapacity b2Island

Hello,

We had a strange bug in some of our levels and we were finally able to reproduce it. I had to write a scene exporter that exports our bodies/shapes to a testbed test but now it crashes in the testbed too.

Code:
Assertion failed: m_contactCount < m_contactCapacity, file Box2D/Dynamics/b2Island.h, line 74


The testbed is attached. I know the number of fixtures is quite heavy and the bodies are in an invalid state at some point but we got the same bug in a different case and in normal conditions (but this one was harder to reproduce).

The crash happens only after some time from the start of the test.

Remi Gillig.
Thanks. I'll take a look.
This diff in b2World.cpp fixes the bug but I don't know if it's the right way :
Code:
@@ -742,6 +742,11 @@
             {
                b2Contact* contact = ce->contact;
 
+                    if (island.m_contactCount >= island.m_contactCapacity)
+                    {
+                        continue;
+                    }
+
                // Has this contact already been added to the island?
                if (contact->m_flags & b2Contact::e_islandFlag)
                {
Fixed. Thanks!
In case anyone is wondering, I had this assert in Linux when compiling with gcc, but not with the Visual C++ version with the same code/data.

Applying the patch to b2World.cpp solved it. Thanks!

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