Fix crash bad_weak_ptr