Creating shapes in thread gives all sorts of errors

I created a thread (using SDL) besides the main program and in this thread I create bodies and shapes. I get all sorts of assertion errors after calling CreateShape for example:
"Assertion failed: pair->IsBuffered()"
"Assertion failed: m_boradPhase->TestOverlap(proxy1, proxy2) == true"

Rarely there are no errors, but nothing gets created. It works fine without the thread.
mm2d wrote:
I created a thread (using SDL) besides the main program and in this thread I create bodies and shapes.

The quick answer: you can't do it.

The longer one: you can do it, but you'll need to set things up carefully so that execution of these world-altering operations is deferred until after the step has stopped, since Box2d is not thread-safe. It's a real pain to do, and you'll probably have to have a real good grasp of threading in order to make it work; I don't know how SDL threads work, but you'll want to lock around both the time step and each of your world-altering calls.

Is there a particular reason you need to do this stuff from a different thread?
I dynamically load the map from the disk. So there is a visible glitch if it's not asynchronous. I'll try to do some simple mutex and see how it goes.

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