Factor out stack overflow reporting