5.7.2.2.1 Runtime Stack Checking

The compiler defines special symbols whose values represent the upper and lower bounds of the memory reserved for the software data stacks when either the hybrid or reentrant stack models have been requested. For the main stack, these symbols are: __stack_lo and __stack_hi. For the interrupt stack on enhanced mid-range devices, they are: __int_stack_lo and __int_stack_hi. For PIC18 devices, the symbols for high- and low-priority interrupt stacks are respectively: __inthi_stack_lo and __inthi_stack_hi, and __intlo_stack_lo and __intlo_stack_hi.

These symbols can be accessed from C code and used at runtime to ensure that the address of the stack pointer has not moved outside the reserved stack memory. The symbols will be automatically declared when you include <xc.h> into your source. They could be used in code similar to the following, which seperately compares the stack pointer stored in FSR1 against the low and high bounds of the main stack.
#include <xc.h>
if(FSR1 < (unsigned short)&__stack_lo)
 stackError();
if(FSR1 >= (unsigned short)&__stack_hi)
 stackError();

This feature is only relevant for the software stack, whose size varies at runtime. There is no equivalent method available for the compiled stack, which is statically allocated.