Prolog (SWI), 26 bytes (error: 25 bytes)
a :- a ; a ; a ; a ; a ;a.
Try it online!
This will generate the error:
ERROR: Out of local stack (which is, as far as I know, the shortest error message that can be generated by SWI-Prolog).
The above program can be simplified to
a :- a ; a. (the other
; as are here so that the program is longer than the error message).
The above program says:
a :- . % For a to be true…
a % Either a…
; % …or…
a % …a must be true
This is obviously infinitely recursive, hence why we get an
Out of local stack error.
However, the following program:
a :- a.
is also infinitely recursive but will never crash. This is because in that case, tail recursion optimization occurs so that the recursive call does not consume memory.
a :- a ; a. is also tail recursive; however we have introduced a disjunction with
; which prevents the recursive call from not consuming memory, because Prolog has to remember that there was another choice possible to explore instead of each recursive call.
It is possible to generate this same error with other approaches (e.g. using
length(_,1000000000) to generate a list too big to fit in memory), but this one is probably the coolest looking one.