This error typically occurs when a function has too many local variables, and the Ethereum Virtual Machine (EVM) imposes a limit on the number of variables that can be pushed onto the stack.
Here the follows investigation that I made today.
References of some examples are given here: