As always, try checking the stack, when it crashes, it will give you an idea, what went wrong