View Issue Details

IDProjectCategoryView StatusLast Update
0006276SOGoSOPEpublic2026-12-01 06:17
Reporterfselles Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Summary0006276: 5.12.14: sogo.log flooded with "invalid month given - 0" (full-history timezone files + iCalTimeZonePeriod assumes BYMONTH)
Description

Full disclosure: the analysis was done with the help of an AI assistant; the diagnosis and the workaround were confirmed on our production server.

Tested on SOGo/SOPE 5.12.14, upgraded from 5.12.13. The product version list may not offer 5.12.14.

Tested on SOGo/SOPE 5.12.14, upgraded from 5.12.13. The product version list may not offer 5.12.14.

Right after upgrading, sogod logs this GNUstep warning tens of thousands of times an hour: about 156,000 lines in the first 38 minutes, against a few dozen a day with 5.12.13.

sogod[PID:TID] File NSCalendarDate.m: 1548. In -[NSCalendarDate initWithYear:month:day:hour:minute:second:timeZone:] invalid month given - 0

Almost all of them come from the web UI views Calendar/eventsblocks and Calendar/eventslist, up to about 15,000 in a single request when the calendars shown contain recurring events. CalDAV REPORTs produce very few. The computed times appear correct. The cost is the log volume (and anything that ingests sogo.log) plus extra work for every date converted.

Cause:

  1. Commit 8ae9feb ("chore(timezones): keep history") ships zone files with their historical periods. 121 of the 597 files now contain an RRULE without BYMONTH; 5.12.13's files contain none. Example, Europe/Madrid.ics:

    BEGIN:STANDARD
    TZNAME:WET
    TZOFFSETFROM:+0100
    TZOFFSETTO:+0000
    DTSTART:19181007T010000
    RRULE:FREQ=YEARLY;UNTIL=19191007T000000Z
    END:STANDARD

    Others affected include Europe/Rome, Europe/Budapest and Europe/Lisbon.

  2. -[iCalTimeZone periodForDate:] (SOPE/NGCards/iCalTimeZone.m, through -_occurrenceForPeriodNamed:forDate:) asks every period whose DTSTART year is at or before the date's year for its occurrence. With the history files that is 15 to 30 periods instead of 2.

  3. -[iCalTimeZonePeriod occurrenceForDate:] (SOPE/NGCards/iCalTimeZonePeriod.m) still calls -_occurrenceForDate:byRRule: when the rule's UNTIL is long past (the last "else if" branch), and only compares the result with UNTIL afterwards.

  4. -_occurrenceForDate:byRRule: builds the start of the period with

    month: [[[rrule byMonth] objectAtIndex: 0] intValue]

    -[iCalRecurrenceRule byMonth] returns nil when there is no BYMONTH, so the month is 0 and GNUstep logs the warning. The comment above the method ("We assume that a RRULE for a timezone will always be YEARLY with a BYMONTH and a BYDAY rule") no longer holds for the history files. Some of them also use BYMONTHDAY (e.g. BYMONTH=10;BYMONTHDAY=2,3,4,5,6,7,8;BYDAY=SU), which this method ignores.

  5. -[iCalDateTime timeZone] prefers SOGo's own zone file over the event's VTIMEZONE, so every stored event with one of these TZIDs goes through this code. The web UI does it once per occurrence, through -[SOGoAppointmentFolder fixupCycleRecord:cycleRange:firstInstanceCalendarDateRange:withEventTimeZone:] -> -periodForDate:.

5.12.14's new WindowsZones.plist also routes some Windows names to affected zones, e.g. "Central Europe Standard Time" -> Europe/Budapest.

Suggested fix (not compiled or tested):

a) In -[iCalTimeZonePeriod occurrenceForDate:], don't compute an occurrence for a rule that ended in an earlier year. With a valid month that computation always ends in nil anyway, because the occurrence falls after UNTIL:

   else if ([rrule untilDate] == nil || [refDate compare: [rrule untilDate]] == NSOrderedAscending)
     tmpDate = [self _occurrenceForDate: refDate byRRule: rrule];
   else if ([refDate yearOfCommonEra] > [[rrule untilDate] yearOfCommonEra])
     tmpDate = nil;   /* rule ended in an earlier year */
   else if ([[self _occurrenceForDate: refDate byRRule: rrule] compare: [rrule untilDate]] == NSOrderedAscending)
     tmpDate = [rrule untilDate];

b) In -_occurrenceForDate:byRRule:, without BYMONTH fall back to DTSTART's month, as RFC 5545 specifies for FREQ=YEARLY:

   NSArray *byMonth = [rrule byMonth];
   int month = byMonth ? [[byMonth objectAtIndex: 0] intValue] : [[self startDate] monthOfYear];

c) Possibly also skip periods whose rule ended before the date in -_occurrenceForPeriodNamed:forDate:, so a date doesn't walk the whole history every time, and handle BYMONTHDAY.

Steps To Reproduce
  1. Run SOGo 5.12.14 with its shipped zone files.
  2. Create a recurring event (e.g. weekly) with TZID Europe/Madrid, or Europe/Rome, Europe/Budapest, Europe/Lisbon.
  3. Open the week or month view of that calendar in the web UI.
  4. sogo.log gets one "invalid month given - 0" warning per occurrence computed.
  5. Replace the zone files with 5.12.13's (see Additional Information), restart sogod, open the same view: no warnings.
Additional Information

Environment: Rocky Linux 8, gnustep-base 1.27.0-6.el8 (it has been this way since the installation, with no such warnings before 5.12.14), PostgreSQL. The month 0 is computed by SOPE, and GNUstep only reports it, so the gnustep-base version shouldn't matter. Calendars used from the web UI and over CalDAV (Thunderbird, DAVx5, iOS/macOS).

Workaround in production: putting back 5.12.13's .ics files in .../Libraries/Resources/NGCards/TimeZones/ and restarting sogod stops the flood. Keep 5.12.14's WindowsZones.plist: every one of its targets exists in 5.12.13's set. The warnings drop back to the few dozen a day seen with 5.12.13, which come from other data.

This issue was investigated with the help of an AI assistant (Anthropic's Claude), by reading the 5.12.13 and 5.12.14 sources and analysing the server's logs. The diagnosis and the workaround were confirmed on a production server; the suggested code changes have not been compiled or tested.

TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2026-12-01 06:17 fselles New Issue