Random Null in world.step()

Not sure if this bug is specific to JBox2D, but it's what I'm using.

The game will run normally, but seemingly at random I get a NullPointerException within world.step(). There's probably a specific reason why this occurs, but I can't find it, nor do I have any idea where to look. Anyone have any ideas as to why this would even occur?
Try to add the jbox2d source code to your project and step into the World.step() method. Or just wait for the exception to be raised, then check the call stack and put some breakpoints.
Step into the method? With a debugger? But, as I said, it appears at seemingly random. If the program pauses every time it hits world.step(), I could be at it forever.
1) Attach jbox2d source to your project
2) Run in debug mode
3) Wait for your random exception
4) Check the call stack
5) Put a conditional breakpoint on the excepting instruction (kind of "stop if var == null")
6) Rerun and wait for the debugger to stop
7) Guess what's wrong 😀
Well I got a stack trace, but it doesn't help me. I mean, I can see where in world.step() that it crashes, but I have no idea what I can do about it.


Code: Select all

04-11 15:47:21.378: E/AndroidRuntime(5822): FATAL EXCEPTION: Thread-20
04-11 15:47:21.378: E/AndroidRuntime(5822): java.lang.NullPointerException
04-11 15:47:21.378: E/AndroidRuntime(5822):    at org.jbox2d.dynamics.ContactManager.addPair(ContactManager.java:73)
04-11 15:47:21.378: E/AndroidRuntime(5822):    at org.jbox2d.collision.broadphase.BroadPhase.updatePairs(BroadPhase.java:191)
04-11 15:47:21.378: E/AndroidRuntime(5822):    at org.jbox2d.dynamics.ContactManager.findNewContacts(ContactManager.java:155)
04-11 15:47:21.378: E/AndroidRuntime(5822):    at org.jbox2d.dynamics.World.solve(World.java:1017)
04-11 15:47:21.378: E/AndroidRuntime(5822):    at org.jbox2d.dynamics.World.step(World.java:560)
which version of the engine are you running
The name of the jar file has 2.1.2.
2.1.2.?
Yes, 2.1.2
Sorry, 2.1.2.x, what is x?

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