<html><body>
<p> </p>
<blockquote>
<div class="message_header"><span>Sun Apr 01 2012 05:13:00 EDT</span><span>from "Robie Basak" <robie.basak@canonical.com> </span><span class="message_subject">Subject: [Freeassociation-devel] Memory corruption in timezone handling</span></div>
<div class="message_content"><tt>Hi freeassociation-devel,</tt><br /><br /><tt>I think I've tracked down a segfault in evolution to a bug in libical.</tt><br /><br /><tt>In icaltimezone.c:icaltimezone_get_builtin_timezone,</tt><br /><tt>icalarray_append(builtin_timezones, ...) is called. This can cause</tt><br /><tt>icalarray_expand() to be called, moving the entire builtin_timezones</tt><br /><tt>array and thus invalidating any previous pointers into the array.</tt><br /><br /><tt>It seems that evolution is expecting icaltimezone pointers to be stable</tt><br /><tt>over time But the icaltimezone structure contains builtin_timezone</tt><br /><tt>which is a pointer into the builtin_timezones array. When</tt><br /><tt>icaltimezone_get_builtin_timezone is later called, it expands the array,</tt><br /><tt>invalidating the builtin_timezone field of any icaltimezone pointer</tt><br /><tt>previously issued by icaltimezone_new. This causes later memory</tt><br /><tt>corruption through access to freed memory and an eventual segfault.</tt></div>
<div class="message_content"> </div>
<div class="message_content"> </div>
</blockquote>
<div class="message_content">from the point of when to have a const pointer and when not, I realy think the whole tz loading & using solution is flawed.</div>
<div class="message_content">imho we should load that list into memory at start (so the application needs to call an libical-init which opens the configuration and loads it into memory) </div>
<div class="message_content">and work with const pointers all over the place later on.</div>
<div class="message_content">I tried to get a consistant scheme which functions need const pointers, and which don't but didn't get to a point where I had a situation that would work without casting off the const in some place.</div>
<div class="message_content">Your valgrind log exactly points out that its fundamentaly broken and needs to be fixed.</div>
<div class="message_content"> </div>
<div class="message_content">So, we probably need to align on a scheme to centraly load the timezone, and remove the implicit loading from all other (deeper) places.</div>
<div class="message_content">This will also remove probable race conditions when working in threaded mode.</div>
<div class="message_content">This will have to break the ABI.</div>
<div class="message_content"> </div>
<div class="message_content">Wilfried Goesgens</div>
</body></html>