Implement stack overflow protection