I passed a TTree to another function and set branch addresses there for 3 variables a b c, and then I set the branch address in the main function again for 2 variables a b, then set fault occurs when I try to GetEntry(). Why?
The variables the addresses of which you are using are allocated on the stack of the function you mention. When returning these addresses become invalid.