On Mon, 2008-09-08 at 23:55 -0400, IGnatius T Foobar wrote: > Patrick Ohly wrote: > > In the upstream libical certain functions return char * pointers into > > memory stored in ring buffers. The caller must not free those pointers. > > The drawback is that the life time of those strings is not predictable. > > > > In the current Evolution libical, those same functions (not renamed!) > > return copies of the string which the caller has to free. Code which was > > written using the old semantic of the calls will leak memory. Code > > adapted to the new semantic (like Evolution) will crash when combined > > with the upstream libical without the same patch. > > > Ok, I definitely see the benefit there. This is similar to POSIX calls > which now offer alternative versions (usually with "_r" appended to the > name) that don't use a static buffer or a ring buffer, in order to be > reentrant? > > If all users of the upstream libical are willing to adapt their code, > > then the best solution would be to simply import the Evolution patch > > into upstream. > > > As much as I'd like to see that happen, I don't think it's realistic. > libical is used by dozens of downstream projects, and a sudden forced > API change is likely to encourage them to fork (or stay forked, if > they've already done so) -- exactly the opposite of the end we are > trying to achieve! > > If there is resistance against that, then we could provide two versions > > of each of these API calls: one with the old name and old behavior and > > one with the new behavior and a name suffix. > That seems more realistic. The alternative might be to offer a global > flag that tells libical to behave one way or the other? (I think > something like that was suggested at some point.) > > While I definitely think the new method of memory allocation makes far > more sense (we'll definitely use it in Citadel, as all of our code is > multithreaded) -- expecting the entire community to perform a "flag day" > API change in lockstep is likely to cause confusion and delay. If we > pursued either the alternate function names or the global flag, is there > likely to be any pushback from the Evolution team? I do not feel having alternate function names would be a better solution.
Consider the following API which remains the same before and after the memory fixes, char * icalcomponent_as_ical_string (icalcomponent *icomp); The returned memory from this API was internally handled by libical before and now its given to the caller. Though the return type gives an indication that the memory is owned by caller, it was not the case. So having a new API for this and changing the behavior does not look to be a good solution since the underlying memory allocation had to be changed. Similarly even with other APIs which return const char* values, the memory can be overwritten at any time. While removing the ring buffer return type's of all the APIs had to be changed from const char * to char *. Is it really worth it to have the old unstable APIs which can crash the application randomly ? My answer would be NO. This is not just a problem with multi-threaded programs. The crash could happen once the ring buffer gets full and starts overwriting the used memory. Since we statically link to libical and expose it via libecal, we have updated the library versions of libecal. We have an additional flag check (hack) also for it now with a warning as in http://bugzilla.gnome.org/show_bug.cgi?id=528986 . So it is better to inform all the stake holders about the change and let them depend on the library versions to decide whether to free the memory or not if they have a need to depend on the older versions of libical. I think no one deny to make the necessary changes knowing that the old API is not very stable. Atleast once I noticed the problem. I made this patch and made all the changes required in evolution, evolution-exchange and evolution-data-server. I would not really like to change them again with new APIS :) thanks, Chenthill. _______________________________________________ Evolution-hackers mailing list Evolutionemail@example.com http://mail.gnome.org/mailman/listinfo/evolution-hackers