GW-Basic, 18 bytes
In GW-Basic there's no separate stack overflow error as such; when the stack overflows you get error 7, ‘Out of memory’. The trick is to make sure you got this because you've ran out of stack space and not for some other reason. Enter:
CLEAR,,241:?SIN(0)
This will immediately result in:
Out of memory
Ok
The number 241
is important. Firstly, it cannot be 0
because that will yield error 5 ‘Illegal function call’. But it also cannot be 240
or less, because although you will get the out of memory error above, CLEAR
won't actually have adjusted the stack space. So in that case the error isn't a real stack overflow, but it acts more like an illegal argument error of sorts. ‘This is too small for us to work with at all, no can do, sorry.’ You can easily check this:
CLEAR,,999
Ok
CLEAR,,1
Out of memory
Ok
?SIN(0)
0
Ok
CLEAR,,240
Out of memory
Ok
?SIN(0)
0
Ok
CLEAR,,241
Ok
?SIN(0)
Out of memory
def s{def t=s;t}
? \$\endgroup\$