I'm asking this question to help others who run into the same problem I ran into. The error is, at least sometimes, misleading and might not be accurate.
The context in which this error is relevant is signing a raw transaction that you created with bitcoin software. This is a common practice for those who are paranoid, like me. Here's the basic procedure:
- Identify the TxOuts (txid and vout pairs) that you want to spend.
- Use https://chainquery.com/bitcoin-api/createrawtransaction or something similar to create a hex string.
- Use https://chainquery.com/bitcoin-api/signrawtransaction along with the private keys required to spend those unspent TxOuts.
In that third step, you might get this "operation not valid with the current stack size" error.