After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 727250 - crash (segmentation fault) when typing comma (,)
crash (segmentation fault) when typing comma (,)
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
3.12.x
Other Linux
: High critical
: ---
Assigned To: gcalctool maintainers
gcalctool maintainers
3.12.1
: 727917 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-03-28 14:49 UTC by Andreas Henriksson
Modified: 2014-04-09 20:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
validate returned iterator before passing to get_buffer (1.17 KB, patch)
2014-03-30 17:23 UTC, Andreas Henriksson
needs-work Details | Review
validate iterator to avoid crash (2.54 KB, patch)
2014-04-06 15:55 UTC, Andreas Henriksson
none Details | Review
git format-patch (2.65 KB, patch)
2014-04-06 18:01 UTC, Andreas Henriksson
committed Details | Review

Description Andreas Henriksson 2014-03-28 14:49:26 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.
Comment 1 Andreas Henriksson 2014-03-30 17:23:53 UTC
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.
Comment 2 Andreas Henriksson 2014-03-30 17:30:10 UTC
(note: with the proposed patch, using ',' as a decimal separator now actually works! Using '.' also works.)
Comment 3 PioneerAxon 2014-04-01 19:40:37 UTC
Review of attachment 273297 [details] [review]:

It doesn't work for me.
The issue still remains.
Comment 4 PioneerAxon 2014-04-01 19:41:30 UTC
The stacktrace is as following.


  • #0 _gtk_text_btree_get_chars_changed_stamp
    at /build/buildd/gtk+3.0-3.10.7/./gtk/gtktextbtree.c line 542
  • #1 gtk_text_iter_make_surreal
    at /build/buildd/gtk+3.0-3.10.7/./gtk/gtktextiter.c line 172
  • #2 gtk_text_iter_get_buffer
    at /build/buildd/gtk+3.0-3.10.7/./gtk/gtktextiter.c line 393
  • #3 variable_completion_provider_real_populate
    at math-display.c line 2193
  • #4 ??
    from /usr/lib/x86_64-linux-gnu/libgtksourceview-3.0.so.1
  • #5 ??
    from /usr/lib/x86_64-linux-gnu/libgtksourceview-3.0.so.1
  • #6 g_timeout_dispatch
    at /build/buildd/glib2.0-2.38.2/./glib/gmain.c line 4451
  • #7 g_main_dispatch
    at /build/buildd/glib2.0-2.38.2/./glib/gmain.c line 3066
  • #8 g_main_context_dispatch
    at /build/buildd/glib2.0-2.38.2/./glib/gmain.c line 3642
  • #9 g_main_context_iterate
    at /build/buildd/glib2.0-2.38.2/./glib/gmain.c line 3713
  • #10 g_main_context_iteration
    at /build/buildd/glib2.0-2.38.2/./glib/gmain.c line 3774
  • #11 g_application_run
    at /build/buildd/glib2.0-2.38.2/./gio/gapplication.c line 1635
  • #12 calculator_main
    at gnome-calculator.c line 1338
  • #13 __libc_start_main
    at libc-start.c line 260
  • #14 _start

Comment 5 Andreas Henriksson 2014-04-02 06:47:53 UTC
(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.
Comment 6 PioneerAxon 2014-04-06 06:07:32 UTC
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".
Comment 7 Andreas Henriksson 2014-04-06 08:46:45 UTC
(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
Comment 8 Andreas Henriksson 2014-04-06 15:55:51 UTC
Created attachment 273665 [details] [review]
validate iterator to avoid crash

patch I used in debian package revision 3.12.0-2 of gnome-calculator.
Comment 9 PioneerAxon 2014-04-06 17:51:03 UTC
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. :)
Comment 10 Andreas Henriksson 2014-04-06 18:01:20 UTC
Created attachment 273668 [details] [review]
git format-patch
Comment 11 PioneerAxon 2014-04-06 20:23:28 UTC
Review of attachment 273668 [details] [review]:

Thanks for the patch. :)

Applied.
Comment 12 PioneerAxon 2014-04-07 10:17:51 UTC
*** Bug 727723 has been marked as a duplicate of this bug. ***
Comment 13 PioneerAxon 2014-04-09 20:18:32 UTC
*** Bug 727917 has been marked as a duplicate of this bug. ***