GNOME Bugzilla – Bug 727944
crash during Empathy startup: segfault in g_date_time_to_utc from _edsf_persona_update
Last modified: 2014-04-21 16:42:56 UTC
<http://bugs.debian.org/744078> is an Empathy crash. We don't have a detailed backtrace with debug symbols yet, but it's a segfault in g_date_time_to_utc() as called by _edsf_persona_update(). <https://bugs.archlinux.org/task/39200> appears to be the same bug. Again, no debug symbols. Looking at the source code, var d = new DateTime (Persona._local_time_zone, (int) bday.year, (int) bday.month, (int) bday.day, 0, 0, 0.0); if (this._birthday == null || (this._birthday != null && !((!) this._birthday).equal (d.to_utc ()))) { this._birthday = d.to_utc (); this.notify_property ("birthday"); } the only way I can see for that to crash is if d was NULL, which could happen if one of bday.year, bday.month, bday.day is out-of-range. I've asked the bug submitter whether they have any contacts with an impossible birthday like 31st February. A possible patch: --- a/backends/eds/lib/edsf-persona.vala +++ b/backends/eds/lib/edsf-persona.vala @@ -1176,9 +1176,12 @@ public class Edsf.Persona : Folks.Persona, * /etc/localtime, which means lots of syscalls. */ var d = new DateTime (Persona._local_time_zone, (int) bday.year, (int) bday.month, (int) bday.day, 0, 0, 0.0); - if (this._birthday == null || + + /* d might be null if their birthday in e-d-s is something that + * doesn't make sense, like 31st February. If so, ignore it. */ + if (d != null && (this._birthday == null || (this._birthday != null && - !((!) this._birthday).equal (d.to_utc ()))) + !((!) this._birthday).equal (d.to_utc ())))) { this._birthday = d.to_utc (); this.notify_property ("birthday");
That looks like the right fix, and even if it doesn’t fix this specific bug (although as you say, there doesn’t seem to be any other way that code can crash), it’s the correct thing to do. Would you mind committing that patch to master, including an update to NEWS please? We also need to fix all other calls to ‘new DateTime()’ and friends to handle null return values correctly.
Created attachment 274772 [details] [review] eds: Fix crash on handling invalid birthday dates from contacts If a GDateTime cannot be constructed due to the requested date being invalid or out of range, the constructor will return null. The code was not previously handling this.
Created attachment 274773 [details] [review] telepathy: Fix crash on handling invalid birthday dates from contacts If a GDateTime cannot be constructed due to the requested date being invalid or out of range, the constructor will return null. The code was not previously handling this.
Created attachment 274774 [details] [review] tracker: Fix crash on handling invalid birthday dates from contacts If a GDateTime cannot be constructed due to the requested date being invalid or out of range, the constructor will return null. The code was not previously handling this.
Created attachment 274775 [details] [review] tests: Add assertions to check for null DateTimes If the DateTime would end up being invalid, construction fails and null is returned. Gracefully catch that in the unit tests.
Review of attachment 274772 [details] [review]: Looks good
Review of attachment 274773 [details] [review]: Looks good
Review of attachment 274774 [details] [review]: Looks good
Review of attachment 274775 [details] [review]: Looks good, just needs an entry in NEWS
The first patch adds the NEWS entry. All merged to master. Attachment 274772 [details] pushed as 5e82482 - eds: Fix crash on handling invalid birthday dates from contacts Attachment 274773 [details] pushed as f3c9b4b - telepathy: Fix crash on handling invalid birthday dates from contacts Attachment 274774 [details] pushed as 48f5e70 - tracker: Fix crash on handling invalid birthday dates from contacts Attachment 274775 [details] pushed as 0085cb4 - tests: Add assertions to check for null DateTimes