This is not a complete answer. From what I've done so far:
I believe that the problem might lie in the initial conditions that you've set
there is also a numerical problem or algorithm problem
I had to modify the code to simplify it to only two variables to do some basic checking. (See below).
For the parameters I've set:
m1, m2 = 1
k1, k2, k3 = 0.5