fix crash on lock-unlock