Problem with revolute joints

I am trying to make a kind of snake using elongated boxes joined with revolute joints. The idea is to enable the motors on these joints and set a variable velocity to them, say a sinusoidal velocity, and then watch the snake move.

The problem I find is that the joints get long as time goes by, and the segments of the snake get further apart. I read in the tutorials that under certain circumstances this may happen, for example when two bodies are involved that have dissimilar masses. But in the case of the snake every segment is of equal density. Maybe this has to do with the velocity of the motors, but I don't know.

Can anyone point out to the cause of the problem?

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