You have the following code
dt = (r1+r2-d)/(vp1-vp2);
What if vp1==vp2???
You also have the following code
//First calculate the component of velocity in the direction of (dx,dy)
CGFloat vp1= speed.x*dx/d+speed.y*dy/d;
CGFloat vp2= collideeSpeed.x*dx/d+collideeSpeed.y*dy/d;
What if d==0???
It could also be other kind of bug in your code. You need to trace the code (find out value for variables) and try to find out the problem.
It is not easy to find the bug. Good luck!