Why do I get data corrupted on the stack when using MPLAB® XC8 v1.30 or later?
Starting with version 1.30 of MPLAB® XC8 compiler, the stack feature is added. This feature affects the stack memory allocation. This new option can be configured in MPLAB XC compiler through the Project Settings > XC8 global options > Option categories > Stack options > STACK TYPE.
You can find more details about this option in the "STACK: Specify Data Stack Type For Entire Program" section of the "MPLAB® XC8 C Compiler User's Guide". You must configure this option according to the code used.