Hello Ningyinggen,
You might try increasing the size of the stack. When the stack is too small, more often the stack will over-write static variables. However, it is also possible that a write to a static variable, within an ISR, can corrupt the stack under these circumstances.
If the unspecified device that you are using has a very small amount of RAM, another possibility is to allocate global/static variables to zero page RAM. This would allow you to increase the stack size. With a small device, it is also inadvisable to attempt to implement floating point operations. Nested interrupts should also be avoided. These require copious quantities of stack.
Regards,
Mac