What you describe is a "classic" case of seasonal expansion and contraction. The problem stems from excessive dampness due to poor attic ventilation and/or a poorly insulated attic. The moisture content of the framing members (rafters and ceiling joist) in the attic (above the second floor) increases during the "damp" season and, thus, expand. This expansion causes the roof/ceiling framing to "pull away" from the wall framing resulting in the gap between your walls and ceilings. The problem will disappear when the weather warms and the framing dries out.
The reason that it is occurring on the second floor and not on the ground floor is the fact that the attic area is subject to moisture and condensation more readily than the area between floors. Moreover, the condition is manifesting itself at the interior walls rather than the perimeter for a couple of reasons; attic ventilation is usually most prevalent at the perimeter which would prevent condensation and, hence, expansion. Another possible reason is that interior walls are usually not insulated. The heat in your home is, therefore, allowed to escape through the walls into the cool attic. Consequently, condensation occurs at the ceiling joist causing them to expand.
You can solve the problem by taking the following steps:
- Make sure that your attic is well ventilated. Add eave vents, gable venting, a ridge vent or turbine ventilator.
- Be certain that household exhaust fans (range top, bathroom and laundry) DO NOT discharge into the attic.
- Check to make sure that the attic is well-insulated -- R-38 minimum and more if you live in a cold climate.
- Control air infiltration by installing gaskets at electrical outlets and switches.
Keep in mind that you will only "minimize" expansion by taking these steps. Some cracking at the wall to ceiling connection may continue to occur. You can further prevent cracking by making sure the ceiling joist are securely anchored to the top of the wall framing with nails, screws or L-brackets.