Print stack overflow messages for Windows, Linux and OS X

Fixes #17562