If the gap is greater than 180
days, you are not allowed to do AOS and subject to the 3 or 10 years ban depened on how long you have overstayed your status. The only exceptions I know are 1) 245(i), for the families whose PD are before 4/30/2001 2) spouse of citizen, the spouse of GC is not protected.