I've been thinking about gradient flows in the context of Morse theory, where we take a differentiable-enough function $f$ on some space (for now let's say a compact Riemannian manifold $M$) and use the trajectories of the gradient flow $x'(t) = - \operatorname{grad} f(x(t))$ to analyse the space. In particular the (un)stable manifolds $$W^\pm(p) = \{ x \in M | x \to p \textrm{ under gradient flow as } t \to \pm \infty\}$$of critical points $p$ must fill up the whole space, which means that the gradient flow from each point must converge to a critical point of $f$.
Most references (I've been using Jost's Riemannian Geometry and Geometric Analysis) simply claim that when $f$ is Morse (has non-degenerate Hessian at all critical points) the gradient flow always converges and then move on, without any discussion of what can go wrong in the degenerate cases. For the purposes of Morse theory this is no problem (since there are a wealth of Morse functions anyway), but I'm curious about what the counterexamples look like.
I have no trouble proving that the flow converges in the Morse case, but I've had trouble finding an example of a function and an initial point for which the flow does not converge. In such a case the flow would necessarily be asymptotic to some subset of the critical set of $f$, just not necessarily to a single critical point. I discussed this with someone a while ago and was told that the flow would always converge in the real-analytic category, so any local examples would be given by non-analytic $f$. It was suggested to me that a function whose graph over a flat subset looked like an infinitely long "groove" cut out of a bump (something like with the edges of the groove smoothed out) would do the job (with the flow proceeding down the groove forever); but upon further thought it seems such a function would fail to be differentiable at the accumulation circle. (Edit: in retrospect, I think this idea does work - if the depth of the groove decayed fast enough, such a function can be differentiable, just not analytic.)
Does anyone know any non-trivial (there are the obvious examples of unbounded functions on non-compact manifolds) examples of how the a trajectory of gradient flow can fail to converge? I'm particularly interested in the simple case of compact manifolds, but anything is welcome. Necessary conditions (or sufficient conditions less restrictive than Morse) for convergence might also be interesting.