In Apollo-11, during preparations for docking with Command and Service Module in lunar orbit, Armstrong and Aldrin managed to put Lunar Module Primary Guidance System Inertial Measurement Unit (IMU) into gimbal lock.Source
127:53:21 Armstrong (onboard): That roll's pretty far. I don't know just how much - so that's - Oh, it's going to go gimbal lock! 127:53:28 Aldrin (onboard): That's it - going to AGS? 127:53:32 Armstrong (onboard): Yes, [garble] Att Deadband.
Armstrong, from 1969 Technical debrief: "... No doubt, we were firmly ensconced in gimbal lock. We had all the lights on, the DAP was not operating anymore, we had no control outputs, clearly no CDU outputs were being processed, so we just put it in AGS and completed the docking in AGS."
In LM, apparently, there was a back-up guidance system : Abort Guidance System (AGS)
This system was not as accurate as the primary IMU but allowed to perform basic attitude control for docking with CSM.
What was the back-up plan in case the CSM Primary Guidance System IMU was put into gimbal lock (especially on the trip back from the moon, after separation from LM)?