Variables accessed from both interrupt and main-line code can easily become corrupted or misread by the program. Such variables should be qualified as "volatile". This will prevent the compiler from using cached copies of the variable in main line code from the Interrupt Service Routine code and vice versa. Volatile qualified variables will also not be optimized away. The compiler will also attempt to access the variable atomically, but this is not always possible if the assembly instruction set does not permit this.
You can check the assembly list file to see the assembly code used to access variables and determine if the access is atomic. If it is not, consider disabling the interrupts when it is accessed in main-line code.
Microchip Technology acquires Atmel