#97 galculator-2.1 segmentation fault


I try to use galculator for calculating expression like "46/2".

gdb galculator
GNU gdb (Gentoo 7.5.1 p1) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /usr/bin/galculator...done.
(gdb) run
Starting program: /usr/bin/galculator
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[galculator] configuration file: couldn't open configuration file /home/victor/.config/galculator/galculator.conf for reading. Nothing to worry about if you are starting galculator for the first time. Using defaults.
[New Thread 0xb550ab40 (LWP 30546)]

Program received signal SIGSEGV, Segmentation fault.
alg_stack_append (stack=stack@entry=0x81b04f8, token=...) at calc_basic.c:356
356 calc_basic.c: No such file or directory.
(gdb) bt
#0 alg_stack_append (stack=stack@entry=0x81b04f8, token=...) at calc_basic.c:356
#1 0x0805917a in alg_add_token (alg=0x8076c44 <main_alg>, this_token=...) at calc_basic.c:449
#2 0x0805b034 in on_operation_button_clicked (button=0x81b1320, user_data=0x0) at callbacks.c:173
#3 0x080b7d40 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) quit


  • Simon

    Thanks for your report and the backtrace. For a more complete picture, could you please provide the last three lines of "galculator -v"?

    best, simon

  • Thank you for quick answer.

    Last three lines from galculator -v:
    Compiled against GTK version 3.6.3
    Linked against GTK version 3.6.3
    Quad-precision floating point numbers.

  • Simon

    thanks, so far so good, what compiler are you using?

  • gcc -v
    Using built-in specs.
    Target: i686-pc-linux-gnu
    Configured with: /mnt/slag/portage/sys-devel/gcc-4.7.2-r1/work/gcc-4.7.2/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.7.2 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.7.2 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.7.2/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.7.2/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/i686-pc-linux-gnu/4.7.2/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --with-arch=i686 --enable-objc-gc --enable-languages=c,c++,objc,obj-c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.7.2-r1 p1.5, pie-0.5.5'
    Thread model: posix
    gcc version 4.7.2 (Gentoo 4.7.2-r1 p1.5, pie-0.5.5)

  • Simon

    sorry for being quiet for so long, your reply didn't get forwarded. As you are using gcc, I am kind of clueless. The GTK version isthe only difference to my Ubuntu system - an here, valgrind does not report any memory corruption.

    In current SVN, I migrated some stuff properly to GTK3, maybe you could give that a try?

    svn checkout svn://svn.code.sf.net/p/galculator/code/trunk galculator-svn

    thanks, simon

  • I tried svn-version of galculator. Seems, It works right now.

  • Simon

    Thanks for the effort you put into this. I'll try to release an update of galculator this week.

    best, simon

  • Simon

    • status: open --> closed-fixed
  • Simon

    • status: closed-fixed --> open
  • Simon

    Thanks for letting me know. I tested today on a machine with GTK 3.6.4 and cannot reproduce. Given this and the part of code that segfaults, I suspect the crash to be related to quad-precision arithmetics (that was introduced in 2.0). galculator gets quad-precision support from GCC's libquadmath, are you aware of any problems with __float128/gcc on gentoo?

    Anyway, to further narrow this down and as a work-around, I added an option to disable quadmath support. Could you or someone who is able to reproduce checkout current SVN
    svn checkout svn://svn.code.sf.net/p/galculator/code/trunk/galculator galculator-svn
    ./configure --disable-quadmath

    Verify by the last line of
    galculator --version
    that you have only double precision floating point arithmetic.

    Does galculator still segfault?


  • Mads

    I can't get the configure-script to work...


    am-wrapper: aclocal: warning: auto-detected versions not found (1.9); falling back to latest available
    aclocal-1.13: warning: autoconf input should be named 'configure.ac', not 'configure.in'
    libtoolize: putting auxiliary files in .'. libtoolize: copying file./ltmain.sh'
    libtoolize: Consider adding AC_CONFIG_MACRO_DIR([m4])' to configure.in and libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. libtoolize: Consider adding-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
    automake-1.13: warning: autoconf input should be named 'configure.ac', not 'configure.in'
    configure.in:4: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
    configure.in:4: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation
    automake-1.13: warning: autoconf input should be named 'configure.ac', not 'configure.in'
    src/Makefile.am:13: warning: compiling 'main.c' with per-target flags requires 'AM_PROG_CC_C_O' in 'configure.in'
    configure.in: installing './ylwrap'
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    /root/galculator-svn/missing: Unknown --is-lightweight' option Try/root/galculator-svn/missing --help' for more information
    configure: WARNING: 'missing' script is too old or missing
    checking for a thread-safe mkdir -p... /bin/mkdir -p
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking whether make supports nested variables... yes
    checking whether to enable maintainer-specific portions of Makefiles... no
    checking for gcc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking for style of include used by make... GNU
    checking dependency style of gcc... gcc3
    checking whether NLS is requested... yes
    checking for intltool-update... /usr/bin/intltool-update
    checking for intltool-merge... /usr/bin/intltool-merge
    checking for intltool-extract... /usr/bin/intltool-extract
    checking for xgettext... /usr/bin/xgettext
    checking for msgmerge... /usr/bin/msgmerge
    checking for msgfmt... /usr/bin/msgfmt
    checking for gmsgfmt... /usr/bin/gmsgfmt
    checking for perl... /usr/bin/perl
    checking for perl >= 5.8.1... 5.16.3
    checking for library containing strerror... none required
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ANSI C header files... yes
    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    checking for PACKAGE... no
    configure: error: Package requirements () were not met:

    Must specify package names on the command line

    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.

    Alternatively, you may set the environment variables PACKAGE_CFLAGS
    and PACKAGE_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.

  • Simon

    I uploaded an updated version of configure.in to SVN, that removes most of the warnings. If this does not help, please install automake version 1.11 (you have 1.13 installed). Version 1.11 works for me. Thanks for giving it a try.

  • Mads

    I forced it to aclocal-1.11, automake-1.11, autoheader-2.69 and autoconf-2.69, but unfortunately it still stops at

    checking for PACKAGE... no

    Why should it check for the existence of a package called PACKAGE?

  • Simon

    PACKAGE is a prefix we can choose freely in configure.in, I admit a stupid one. It actually checks for gtk when it says it checks for PACKAGE. I updated configure.in another time in SVN, fixing the naming of the prefix and another flaw that could have an effect on your system. So please "svn update" and give it another try.

    Apart from this, plase make sure you have headers of gtk2 or gtk3 installed. What's the output of
    pkg-config --libs gtk+-3.0
    (or pkg-config --libs gtk+-2.0 resp)?

    thanks for your patience,

  • Mads

    Sorry for late reply, kinda forgot this since the issue was on my work computer, and not my personal.

    I've tested a bit now, both with and without quadmath, and the problem can be reconstructed if you configure like this (on i686):

    CFLAGS="-O2 -march=core2 -pipe" ./configure --enable-quadmath

    The same optimization but without quadmath works fine without segfaults as far as I can see.

  • Simon

    thanks for your reply, I am still not able to reproduce on an ubuntu 13.04 amd64 (gcc 4.7.3, libc 2.17) with given CFLAGS.

    The bugtraces indicate that galculator segfaults after accessing a recently reallocated block of __float128s. However, valgrind logs are fine on my system. Hence, next step would aim at isolating the problem to see who is responsible (maybe certain gcc/libquadmath with -O2 and core2?).

    I'd be interested to further debug this, but would need access to a system where I can reproduce the segfaults.

    for another hint, could you create a valgrind log of a segfaulting galculator with debugging symbols, e.g.

    CFLAGS="-g -O2 -march=core2 -pipe" ./configure --enable-quadmath


    valgrind --log-file=galculator.log --leak-check=full ./galculator

    thanks, simon

  • Sorry for late reply.

    I try CFLAGS="-O2 -pipe -march=pentium-m -fomit-frame-pointer -ggdb" ./configure --enable-quadmath

    And then run gdb ./galculator:
    (gdb) bt:
    #0 alg_stack_append (stack=stack@entry=0x818c920, token=...) at calc_basic.c:356
    #1 0x0805823a in alg_add_token (alg=0x81ccd40, this_token=...) at calc_basic.c:449
    #2 0x08061274 in flex_parser_submit_token (operation=operation@entry=61 '=') at flex_parser.l:212
    #3 0x08061cd2 in yylex () at flex_parser.l:58
    #4 0x0806274d in flex_parser (string=0x81ca700 "38/45") at flex_parser.l:254
    #5 0x0805d933 in on_paper_entry_activate (activated_widget=0x8169000, user_data=0x0) at callbacks.c:1654
    #6 0xb76c20bf in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0
    #7 0xb76c037b in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
    #8 0xb76d24d9 in ?? () from /usr/lib/libgobject-2.0.so.0
    #9 0xb76d9f33 in g_signal_emitv () from /usr/lib/libgobject-2.0.so.0
    #10 0xb7b6d5e6 in ?? () from /usr/lib/libgtk-3.so.0
    #11 0xb7b6db9b in ?? () from /usr/lib/libgtk-3.so.0
    #12 0xb7b6dd15 in ?? () from /usr/lib/libgtk-3.so.0
    #13 0xb7b6efce in gtk_bindings_activate_event () from /usr/lib/libgtk-3.so.0
    #14 0xb7db2e93 in ?? () from /usr/lib/libgtk-3.so.0
    #15 0xb7beb39e in ?? () from /usr/lib/libgtk-3.so.0
    #16 0xb7c68f00 in ?? () from /usr/lib/libgtk-3.so.0
    #17 0xb76bec07 in ?? () from /usr/lib/libgobject-2.0.so.0
    #18 0xb76c0560 in ?? () from /usr/lib/libgobject-2.0.so.0
    #19 0xb76da3b0 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
    #20 0xb76dadc3 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
    #21 0xb7db6591 in ?? () from /usr/lib/libgtk-3.so.0
    #22 0xb7dd3670 in gtk_window_propagate_key_event () from /usr/lib/libgtk-3.so.0
    #23 0xb7dd65b4 in ?? () from /usr/lib/libgtk-3.so.0
    #24 0xb7c68e32 in ?? () from /usr/lib/libgtk-3.so.0
    #25 0xb76bf17d in ?? () from /usr/lib/libgobject-2.0.so.0
    #26 0xb76c037b in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
    #27 0xb76d21a7 in ?? () from /usr/lib/libgobject-2.0.so.0
    #28 0xb76da9d0 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
    #29 0xb76dadc3 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
    #30 0xb7db6591 in ?? () from /usr/lib/libgtk-3.so.0
    #31 0xb7c6695d in ?? () from /usr/lib/libgtk-3.so.0
    #32 0xb7c68ae0 in gtk_main_do_event () from /usr/lib/libgtk-3.so.0
    #33 0xb7a64dfc in ?? () from /usr/lib/libgdk-3.so.0
    #34 0xb7a8fb78 in ?? () from /usr/lib/libgdk-3.so.0
    #35 0xb75cdc25 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
    #36 0xb75cdfd4 in ?? () from /usr/lib/libglib-2.0.so.0
    #37 0xb75ce433 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
    #38 0xb7c67c1d in gtk_main () from /usr/lib/libgtk-3.so.0
    #39 0x08051581 in main (argc=1, argv=0xbfffebd4) at main.c:266

  • At attachment:

    valgrind --log-file=galculator.log --leak-check=full ./galculator

  • Simon

    Still not able to reproduce on Ubuntu. Does anyone have an idea how I can get access to a gentoo machine where I can reproduce this problem? I'd like to get away without installing Gentoo from scrath (apart from not having the right CPU at hand now).

    best, simon

  • Mads

    Can still reproduce it if I compile with use flags. I'm at work now (in CET timezone), but I can give you access to a gentoo machine afterwards. Send me a private message with your desired username and password :)

  • Simon

    Mads, thank you for your offer. sourceforge rejects messages to your mail alias. Could you please check that your "Mail Alias Behavior" in account preferences is configured properly. Alternatively, you could send me a private message to chimaira@users.sf.net so that we can set things up.

    thanks, simon

  • Any news? After upgrade to galculator-2.1.3 and gtk+-3.10.8 galculator segfaults also. I have backtrace for this segfault. If needed I can post backtrace.

  • Simon

    For the ease of discussion, I continue this thread on the gentoo bug tracker, for further reference see: https://bugs.gentoo.org/show_bug.cgi?id=463459#c4