Improve the "Stack space overflow" error; fixes trac #3296