How does this converging function appear to diverge?
Say we have $$f(m) = \int_0^\infty \sin(mx)\frac{dx}{x}$$ and we want to compute the derivative at $m>0.$ We need to take $$\lim_{h\rightarrow0}\frac{f(m+h)-f(m)}{h}. $$ Since both integrals converge, we're free to combine them, and we get $$ f'(m) = \lim_{h\rightarrow0} \frac{1}{h}\int_0^\infty \left(\sin((m+h)x)-\sin(mx)\right)\frac{dx}{x}.$$
In order to come to the conclusion that this equals $\int_0^\infty\cos(x)dx,$ we need to be able to justify bringing the limit inside the integral.
The problem of when you can bring a limit inside an integral is well-studied, and some well-known sufficient conditions for when you can are the Dominated Convergence Theorem and the Monotone Convergence Theorem. Clearly (since the answer would be wrong), this is one case where you can't. This frequently happens in oscillating integrals, but also in lots of other cases as well. In this case, if your integral is relying on cancellation from oscillations to stay finite, taking a limit inside can screw up things.
When you take the limit inside the integral, you are assuming you can treat each point $x$ inside the integral uniformly as $h\rightarrow 0$. Sometimes, however, the global behavior of the integral is changed when you do this. This generally happens when, as $h\rightarrow 0,$ a range of $x$ that contributes significantly to the integral gets 'squeezed onto the boundary', or 'pushed off to infinity'.
A nice example, a bit different from ours, but where it's easy to see what's going on is $\int_0^\infty hx e^{-\frac{1}{2}hx^2}dx.$ For any $h>0,$ the integral is $1$, which you can verify by substitution. Thus $\lim_{h\rightarrow 0^+}$ of the integral is $1.$ However, taking the limit inside the integral gives $0$ for all $x>0,$ so the integral of the limit is $0 \ne 1$. If you sketch the function for smaller and smaller values of $h$ it's easy to see what's going on. As $h\rightarrow 0^+,$ the function goes becomes a very tall spike, very close to $z=0,$ with area $1.$ When $h$ goes to zero, the spike that contains all the area gets pushed to the boundary at $x=0.$
For our integral, oscillatory cancellations are ' pushed to infinity' in a certain sense as $h\rightarrow 0,$ so taking the limit inside causes a divergence. To see how this works, we can rewrite $$\sin((m+h)x)-\sin(mx) = \sin(mx)\cos(hx)+\cos(mx)\sin(hx) -\sin(mx)$$ so that the integral is $$ \int_0^\infty\frac{\sin(mx)(\cos(hx)-1) + \cos(mx)\sin(hx)}{hx}dx.$$
When you take the limiting form $\sin(hx)\approx hx$ and $\cos(hx)-1)\approx \frac{1}{2}h^2x^2$as $h\rightarrow 0,$ you completely lose the fact that the functions oscillate. Thus the integral, whose convergence was controlled by this oscillating behavior at large periods $x \sim 1/h$ can have its convergence destroyed by taking the limit inside. You are letting $h\rightarrow 0$ at fixed $x$ without appreciating that the function's oscillations when $x$ gets above $1/h$ were the only thing making it converge in the first place. (You're pushing the oscillation period off to infinity, so it no longer actually oscillates.)
Thus when we take the limit $h\rightarrow 0$ inside the integral and get $\int_0^\infty \cos(x)dx,$ which no longer converges, we are no longer quite so surprised.
Going back to the expression $$ f'(m) = \lim_{h\rightarrow0} \frac{1}{h}\int_0^\infty \left(\sin((m+h)x)-\sin(mx)\right)\frac{dx}{x},$$ we can see another angle. Usually, our intuition says the integrand goes to zero like $h$ for $h\rightarrow 0,$ so we can pull the $h$ out of the integrand and be left with the derivative inside. However, as we know now, this only works when things are sufficiently uniform.
What happens in our case, is that even though the difference in $\sin((m+h)x)-\sin(mx)$ goes to zero like $h$ when $h\rightarrow0,$ the integral is actually always zero, for any $h$ (so long as $m+h$ stays positive).
To see this, if you go back to when the integrals were separate and write $$ f'(m) = \lim_{h\rightarrow 0}\frac{1}{h}\left(\int_0^\infty \sin((m+h)x)\frac{dx}{x} - \int_0^\infty \sin(mx)\frac{dx}{x}\right).$$ Since we know the integrals are both convergent, we can change variables. Because of the $dx/x$ they both go to $\int_0^\infty \sin(u)du/u$ which means they're the same and we have $$f'(m) = \lim_{h\rightarrow 0}\frac{1}{h}*0=0,$$ which is the correct answer.
Intuitively, stretching out the sine waves to get more area is exactly cancelled out by fact that the amplitude decays like $1/x$ when it stretches out.