GNOME Bugzilla – Bug 727250
crash (segmentation fault) when typing comma (,)
Last modified: 2014-04-09 20:18:32 UTC
Initially reported at: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742840 since gnome-calculator 3.12 usage of comma now only does not work (see #652362) but actually makes the application crash (sigsegv). It seems to have been introduced with this commit: https://git.gnome.org/browse/gnome-calculator/commit?id=4d64dc9180fd8c54368e26b2da08fcc95f232c10 See: https://git.gnome.org/browse/gnome-calculator/tree/src/math-display.vala#n453 Gtk.TextBuffer text_buffer = context.get_iter ().get_buffer (); get_iter() here seems to return a pointer to an iter-struct with all fields set to 0x0. When this (invalid?) iter is passed to get_buffer () it crashes. Note that several critical warnings has been issued before reaching this crash. Also note that reverting the change doesn't make ',' usable.
Created attachment 273297 [details] [review] validate returned iterator before passing to get_buffer With some helpful pointers from Lethalman I came up with this patch. Maybe not the prettiest solution in the world, but atleast avoids the crash here.
(note: with the proposed patch, using ',' as a decimal separator now actually works! Using '.' also works.)
Review of attachment 273297 [details] [review]: It doesn't work for me. The issue still remains.
The stacktrace is as following.
+ Trace 233424
(In reply to comment #3) > Review of attachment 273297 [details] [review]: > > It doesn't work for me. > The issue still remains. Looks like the same issue might exist in a second place. Could you try modifying around line 505 the same way the patch did? ie. make sure both populate functions has the change.
Sorry for the late reply. I tried replacing both instances with similar fix. It does not crash now, but I'm unable to enter <comma> into text field. It throws some warnings on terminal and that's it. I haven't checked with otehr locales though. I'm running it on locale "en_US.UTF-8".
(In reply to comment #6) [...] > I haven't checked with otehr locales though. I'm running it on locale > "en_US.UTF-8". Maybe that's it.... decimal separator is (in real world) locale dependent, don't know if the code is but could well be. In your locale, I think the 'correct' separator is '.'. In mine (sv_SE.UTF-8), it's ','. A hint might be, how does gnome-calculator show decimal numbers to you? For me it shows them using a ',' .... if they show up with '.' for you, then likely the code is locale dependant. For me, 0.55 - 0,22 = 0,33 in gnome calculator. Also, 0.55 - 0.22 = 0,33
Created attachment 273665 [details] [review] validate iterator to avoid crash patch I used in debian package revision 3.12.0-2 of gnome-calculator.
Andreas, Thanks for the patch. However I'm unable to apply the patch using "git am", as it is generated with git diff. It is important to retain the author information and commit message of the original patch. Can you please post the patch generated using "git format-patch" command? Thank you. :)
Created attachment 273668 [details] [review] git format-patch
Review of attachment 273668 [details] [review]: Thanks for the patch. :) Applied.
*** Bug 727723 has been marked as a duplicate of this bug. ***
*** Bug 727917 has been marked as a duplicate of this bug. ***