Bug 140688 - calendar file grows by 20 megabytes causes korganizer to crash (all system memory exhausted) when any operation on it is performed
Summary: calendar file grows by 20 megabytes causes korganizer to crash (all system me...
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR crash
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-26 23:16 UTC by Michał Kosmulski
Modified: 2007-01-27 10:37 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Kosmulski 2007-01-26 23:16:33 UTC
Version:            (using KDE KDE 3.5.3)
Installed from:    Slackware Packages
OS:                Linux

I noticed just today that my korganizer generated, for no apparent reason, a big change in my calendar file (the change is described below). After this change, the calendar file grew from about 9 to about 34 MB and performing any operation in the calendar, e.g. adding and event or modifying an existing one causes korganizer to first allocate all memory it can get from the system (512 MB RAM and 512 MB swap - one can see the swap fill up withing a dozen or so seconds in the system monitor) and then to crash.
Here is the description of the change korganizer performed. Fortunately, I had a backup from yesterday afternoon and noticed the problem today in the afternoon so I could compare the two versions. I have most probably not performed any editions between the two versions and if any, it was the kind of changes I perform every day (adding a simple event or perhaps moving an existing one around).
I diffed the two versions and here is the significant change:

BEGIN:VEVENT
-DTSTAMP:20070125T174854Z
+DTSTAMP:20070125T221232Z
 ORGANIZER;CN=Anonymous:MAILTO:nobody@nowhere
 CREATED:20070116T224008Z
 UID:KOrganizer-2020110447.714
@@ -132600,7 +132600,340086 @@
  Ã<82>Â<82>Ã<83>Â<82>Ã<82>Â<82>Ã<83>Â<83>Ã<82>Â<83>Ã<83>Â<82>Ã<82>Â<83>Ã<83>Â<83>Ã<82>Â<82>Ã
  <83>Â<82>Ã<82>Â<83>Ã<83>Â<83>Ã<82>Â<83>Ã<83>Â<82>Ã<82>Â<82>Ã<83>Â<83>Ã<82>Â<82>Ã<83>Â<82>Ã<82>
  Â<82>Ã<83>Â<83>Ã<82>Â<83>Ã<83>Â<82>Ã<82>Â<83>Ã<83>Â<83>Ã<82>Â<82>Ã<83>Â<82>Ã<82>Â<82>Ã<83>Â
- <83>Ã<82>Â<83>Ã<83>Â<82>Ã<82>Â<82>Ã<83>Â<83>Ã<82>Â<82>Ã<83>Â<82>Ã<82>³lne
+ <83>Ã<82>Â<83>Ã<83>Â<82>Ã<82>Â<82>Ã<83>Â<83>Ã<82>Â<82>Ã<83>Â<82>Ã<82>Â<83>Ã<83>Â<83>Ã<82>Â<83>

<snip many megabytes (!) of lines like the last line above>

+ Â<82>Ã<83>Â<83>Ã<82>Â<82>Ã<83>Â<82>Ã<82>³lne                                   dane/inne/dzwiek/XXXXXXXXXXXXXXXXXXXX
 ACTION:AUDIO                                                                    TRIGGER;VALUE=DURATION:-PT5M
@@ -132609,7 +472688,7 @@                                                        END:VEVENT

The path in the filesystem of the music file to play should be "wspólne dane/inne/dzwiek/XXXXXXXXXXXXXXXXXXXX". My filesystem uses UTF-8 encoding and apparently, the 'ó' gets garbled by being encoded to UTF-8 multiple times (i.e. the two bytes representing it in UTF-8 are again treated as 8-bit characters and encoded to UTF-8 thus being replaced by 2 bytes each and so on). So it seems like this entry perhaps doubled each time the calendar was saved and just passed the critical size today (because it was garbled in the backed up version too, only several times smaller).

After I manually deleted the offending entry (using vim), the calendar file shrunk to slightly above 700 kB and korganizer handles it without any problems.

I don't know if this could be related to #140211.

Here are my locale setting as printed by "locale" in a new konsole window:
LANG=en_US.UTF-8
LC_CTYPE=pl_PL.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME=en_GB.UTF-8
LC_COLLATE=pl_PL.UTF-8
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=pl_PL.UTF-8
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT=pl_PL.UTF-8
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

My KDE locale is Polish but the KDE language is English.
Comment 1 Reinhold Kainhofer 2007-01-27 00:15:21 UTC
I can confirm this problem. All non-ascii characters in all URLs (attachments, audio alarm file, procedure alarm application) are loaded wrongly (utf8 data is loaded as latin1, but then written back as utf8).
Reinhold
Comment 2 Reinhold Kainhofer 2007-01-27 00:55:16 UTC
SVN commit 627541 by kainhofe:

When loading any url/uri (attachments, audio alarm files, procedure alarm application), make sure we load it as utf8 and not latin1.

By default, QString(const char*) treats the string as latin1, so we need to use QString::fromUtf8 instead.

BUG: 140688


 M  +2 -2      icalformatimpl.cpp  


--- branches/KDE/3.5/kdepim/libkcal/icalformatimpl.cpp #627540:627541
@@ -1204,11 +1204,11 @@
     if (isurl == 0)
       attachment = new Attachment((const char*)icalattach_get_data(a));
     else {
-      attachment = new Attachment(QString(icalattach_get_url(a)));
+      attachment = new Attachment(QString::fromUtf8(icalattach_get_url(a)));
     }
   }
   else if ( value_kind == ICAL_URI_VALUE ) {
-    attachment = new Attachment(QString(icalvalue_get_uri(icalproperty_get_value(attach))));
+    attachment = new Attachment(QString::fromUtf8(icalvalue_get_uri(icalproperty_get_value(attach))));
   }
 
   icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER);
Comment 3 Michał Kosmulski 2007-01-27 10:37:59 UTC
Wow! That sure was a quick fix. Thank you.