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 783095 - gnucash-2.6.16 segfaults on startup
gnucash-2.6.16 segfaults on startup
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: General
2.6.16
Other Linux
: Normal normal
: ---
Assigned To: gnucash-general-maint
gnucash-general-maint
Depends on:
Blocks:
 
 
Reported: 2017-05-25 13:43 UTC by john.frankish@outlook.com
Modified: 2018-06-29 23:57 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description john.frankish@outlook.com 2017-05-25 13:43:11 UTC
On a 64-bit linux-4.8.17 system with glibc-2.24, compiling gnucash-2.6.16 from source with gcc-6.2.0

Nine times out of ten, gnucash segfaults on startup - the splash screen shows and fails part way through.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
58      }
(gdb) bt
  • #0 __GI_raise
    at ../sysdeps/unix/sysv/linux/raise.c line 58
  • #1 __GI_abort
    at abort.c line 89
  • #2 __libc_message
    at ../sysdeps/posix/libc_fatal.c line 175
  • #3 malloc_printerr
  • #4 _int_free
    at malloc.c line 3902
  • #5 gnc_totd_initialize
    from /usr/local/lib/gnucash/libgncmod-gnome-utils.so
  • #6 gnc_totd_dialog
    from /usr/local/lib/gnucash/libgncmod-gnome-utils.so
  • #7 gnc_gui_init
    from /usr/local/lib/gnucash/libgncmod-gnome-utils.so
  • #8 main
    at gnucash-bin.c line 825

Comment 1 John Ralls 2017-05-25 13:56:51 UTC
We'll need a backtrace from a debug build.
What source did you use? If a tarball from Github, was it "gnucash-2.6.16.tar.gz/bz2" or "Source Code (tar.gz)"?
Comment 2 john.frankish@outlook.com 2017-05-25 14:02:15 UTC
I used gnucash-2.6.16.tar.bz2 from sourceforge via the "Getting GnuCash as source code" link on your main page.

By debug build, do you mean using ./configure --enable-debug?
Comment 3 john.frankish@outlook.com 2017-05-25 15:04:50 UTC
I recompiled with "enable-debug", but it did not change the gdb output.
Comment 4 John Ralls 2017-05-25 15:15:50 UTC
Did you remember to do a 'make clean' first?
Comment 5 john.frankish@outlook.com 2017-05-25 15:17:32 UTC
I deleted the source folder and untarred it again :)
Comment 6 john.frankish@outlook.com 2017-05-25 15:18:35 UTC
BTW, the first line of src/gnc-test-env.pl should be /usr/bin/env perl
Comment 7 John Ralls 2017-05-25 15:37:32 UTC
(In reply to john.frankish@outlook.com from comment #5)
> I deleted the source folder and untarred it again :)

Hmm. 
Check the timestamps on the installed libraries and make sure that the ones with debug symbols are there. If they're still the old ones do 'make uninstall && make install' to get the new ones.

If that doesn't work examine the compile output and make sure '-g' is included in the gcc command line. If that's OK too then there's something wrong with your gdb.

(In reply to john.frankish@outlook.com from comment #6)
> BTW, the first line of src/gnc-test-env.pl should be /usr/bin/env perl

Why? That's widely considered a security hole. /usr/bin/perl is present on all BSD and Linux distros and MacOS because it's required for system administration scripts.
Comment 8 john.frankish@outlook.com 2017-05-25 15:42:49 UTC
Yes, "-g" is in the gcc command lines and I removed "-O2" so I didn't get (optimized out).

I don't see what might be wrong with gdb since it completes normally and does not indicate missing information?

perl is at /usr/local/bin/perl on this system..
Comment 9 John Ralls 2017-05-25 16:14:05 UTC
(In reply to john.frankish@outlook.com from comment #8)
> Yes, "-g" is in the gcc command lines and I removed "-O2" so I didn't get
> (optimized out).
> 
> I don't see what might be wrong with gdb since it completes normally and
> does not indicate missing information?

Well, either your gcc is broken (not generating symbols) or gdb is (not displaying the symbols in a backtrace).

> 
> perl is at /usr/local/bin/perl on this system..

Then it's not a supported development platform, sorry.
Comment 10 john.frankish@outlook.com 2017-05-25 16:23:27 UTC
If I compile gnucash and glibc without "-g", I get this:

(gdb) 
  • #0 raise
    from /lib/libc.so.6
  • #1 abort
    from /lib/libc.so.6
  • #2 ??
    from /lib/libc.so.6
  • #3 ??
    from /lib/libc.so.6
  • #4 ??
    from /lib/libc.so.6
  • #5 gnc_totd_dialog
    from /usr/local/lib/gnucash/libgncmod-gnome-utils.so
  • #6 gnc_gui_init
    from /usr/local/lib/gnucash/libgncmod-gnome-utils.so
  • #7 main

..which would seem to indicate that gcc is generating debug sysmbols and besides, it works fine when debugging other stuff.

I am compiling gnucash like this:

./configure --prefix=/usr/local --disable-static --localstatedir=/var --libexecdir=/usr/local/lib --disable-dbi --enable-debug

find . -name Makefile -type f -exec sed -i 's/-O2//g' {} \;

make
sudo make install

..let me know if you'd like it done otherwise.

If you don't want to check where perl is, then fine, but I don't think this qualifies being able to say "then it's not a supported development platform".
Comment 11 John Ralls 2017-05-25 17:55:44 UTC
So you had a -g in CFLAGS when you first submitted the bug? That's all "debug build" means, and removing optimization flags is the only other thing --enable-debug does (and it looks like it's not doing that right).

It's weird that building gnucash with -g makes gdb show symbols from glibc... hmm, the paths in the first stack trace are strange, too.

Rather than doing the sed on Makefiles you can just pass -O0 in CFLAGS. That actually works better because gcc does some optimization by default and -O0 turns that off. I'll go further and suggest that you replace "--enable-debug" with "CFLAGS=$CFLAGS -O0 -g".

Have you run 'make install' after doing a debug build? GnuCash loads its modules (including libgncmod-gnome-utils.so, which is what we need the line numbers from) from the prefix location (/usr/local/lib/gnucash in your case), not from the build directory.

If you have done that, try switching to frame 5 in gdb. Maybe from there you can figure out what it's trying to free that libc doesn't like.



It's not that we don't want to "check where perl is", we don't want to use a possibly malicious perl that an attacker has placed on the user's path. We insist on using the distro-provided perl, and that should be in /usr/bin. If it's not there then you can't run gnc-test-env.pl. That means that you can't run the Guile unit tests and that means that you don't have a platform that's suitable for GnuCash development.
Comment 12 john.frankish@outlook.com 2017-05-26 06:14:51 UTC
In common with most source code, gnucash puts "-g" and "-O2" in the Makefile(s) CFLAGS without the user requesting this.

I tried again with "-O0 -g" (and removed "-O2"), and yes, I have been using "sudo make install"

(gdb) run
Starting program: /usr/local/bin/gnucash 
*** Error in `/usr/local/bin/gnucash': double free or corruption (out): 0x00000000007bf300 ***
======= Backtrace: =========
/lib/libc.so.6(+0x5f2cc)[0x7ffff30142cc]
/lib/libc.so.6(+0x63a45)[0x7ffff3018a45]
/lib/libc.so.6(+0x6467f)[0x7ffff301967f]
/usr/local/lib/gnucash/libgncmod-gnome-utils.so(+0xd28d3)[0x7ffff745a8d3]
/usr/local/lib/gnucash/libgncmod-gnome-utils.so(gnc_totd_dialog+0x59)[0x7ffff745abde]
/usr/local/lib/gnucash/libgncmod-gnome-utils.so(gnc_gui_init+0x32c)[0x7ffff743318b]
/usr/local/bin/gnucash(main+0x1f7)[0x405cba]
/lib/libc.so.6(__libc_start_main+0x15a)[0x7ffff2fd5e9e]
/usr/local/bin/gnucash(_start+0x2a)[0x40339a]
======= Memory map: ========
00400000-00408000 r-xp 00000000 00:02 402879                             /usr/local/bin/gnucash
00607000-00608000 r--p 00007000 00:02 402879                             /usr/local/bin/gnucash
00608000-00609000 rw-p 00008000 00:02 402879                             /usr/local/bin/gnucash
00609000-007d8000 rw-p 00000000 00:00 0                                  [heap]
...
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
58      }
(gdb) bt
  • #0 __GI_raise
    at ../sysdeps/unix/sysv/linux/raise.c line 58
  • #1 __GI_abort
    at abort.c line 89
  • #2 __libc_message
    at ../sysdeps/posix/libc_fatal.c line 175
  • #3 malloc_printerr
  • #4 _int_free
    at malloc.c line 3902
  • #5 gnc_totd_initialize
    at dialog-totd.c line 230
  • #6 gnc_totd_dialog
    at dialog-totd.c line 324
  • #7 gnc_gui_init
    at gnc-gnome-utils.c line 738
  • #8 main
    at gnucash-bin.c line 825
  • #5 gnc_totd_initialize
    at dialog-totd.c line 230


The way this distro works is that everything in the base distro is under /usr and everything that is an add-on is under /usr/local - since perl (14mb) is bigger than the entire base distro, it is an add-on and thus the distro-provided perl is at /usr/local/bin
Comment 13 John Ralls 2017-05-26 14:34:25 UTC
Yay.

In frame 5 what are the values of tip_count and tip_list[tip_count]?

Your distro takes a rather unique view of /usr/local. Given that unique view you should reconsider using /usr/local for any non-distro installations. /opt is a popular alternative. You could also put a symlink to /usr/local/bin/perl in /usr/bin so that the normal shebang works.
Comment 14 john.frankish@outlook.com 2017-05-26 15:12:29 UTC
Hopefully this is what you're after - if not, let me know what gdb command(s) I need to use.

Program received signal SIGABRT, Aborted.
0x00007ffff2fe4bb4 in raise () from /lib/libc.so.6
(gdb) bt
  • #0 raise
    from /lib/libc.so.6
  • #1 abort
    from /lib/libc.so.6
  • #2 ??
    from /lib/libc.so.6
  • #3 ??
    from /lib/libc.so.6
  • #4 ??
    from /lib/libc.so.6
  • #5 gnc_totd_initialize
    at dialog-totd.c line 230
  • #6 gnc_totd_dialog
    at dialog-totd.c line 324
  • #7 gnc_gui_init
    at gnc-gnome-utils.c line 738
  • #8 main
    at gnucash-bin.c line 825
  • #5 gnc_totd_initialize
    at dialog-totd.c line 230
Stack level 5, frame at 0x7fffffffe970:
 rip = 0x7ffff745a8d3 in gnc_totd_initialize (dialog-totd.c:230); saved rip = 0x7ffff745abde
 called by frame at 0x7fffffffe9d0, caller of frame at 0x7fffffffe930
 source language c.
 Arglist at 0x7fffffffe960, args: 
 Locals at 0x7fffffffe960, Previous frame's sp is 0x7fffffffe970
 Saved registers:
  rbp at 0x7fffffffe960, rip at 0x7fffffffe968
(gdb) info args
No arguments.
(gdb) info locals
filename = 0x7bca20 ""
contents = 0x0
new_str = 0x7aa520 "\240k|"
length = 0
error = 0x100403370
Comment 15 John Ralls 2017-05-26 15:46:09 UTC
Nope. The commands are:

p tip_count
p tip_list[tip_count]

and I thought of another:
p g_strv_length(tip_count)

But since contents is NULL, I think I see the problem. Try adding
  tip_list = NULL;
after line 222, g_strfreev(tip_list);

That may fix the crash.
Comment 16 john.frankish@outlook.com 2017-05-26 16:30:49 UTC
Changing dialog-totd.c like this:

    g_strfreev (tip_list);
    tip_list = NULL;
    if (contents)

..seems to move the problem:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff745a922 in gnc_totd_initialize () at dialog-totd.c:228
228         for (tip_count = 0; tip_list[tip_count] != NULL; tip_count++)
(gdb) bt
  • #0 gnc_totd_initialize
    at dialog-totd.c line 228
  • #1 gnc_totd_dialog
    at dialog-totd.c line 325
  • #2 gnc_gui_init
    at gnc-gnome-utils.c line 738
  • #3 main
    at gnucash-bin.c line 825
  • #0 gnc_totd_initialize
    at dialog-totd.c line 228
No arguments.
Comment 17 John Ralls 2017-05-26 16:50:14 UTC
I half expected that, it's from tip_list[tip_count].
The next patch is to move the compress loop into the if (contents) block. Change
    if (contents)
        tip_list = g_strsplit(contents, "\n", 0);

    /* Convert any escaped characters while counting the strings */
    for (tip_count = 0; tip_list[tip_count] != NULL; tip_count++)
    {
        new_str = g_strcompress(tip_list[tip_count]);
        g_free(tip_list[tip_count]);
        tip_list[tip_count] = new_str;
    }

into
    if (contents)
    {
        tip_list = g_strsplit(contents, "\n", 0);

        /* Convert any escaped characters while counting the strings */
        for (tip_count = 0; tip_list[tip_count] != NULL; tip_count++)
        {
            new_str = g_strcompress(tip_list[tip_count]);
            g_free(tip_list[tip_count]);
            tip_list[tip_count] = new_str;
         }
    }

That all of this is happening suggests there's something wrong with /usr/local/share/gnucash/tip_of_the_day.list. Can you check that it's not empty?
Comment 18 john.frankish@outlook.com 2017-05-26 17:31:38 UTC
That seems to have fixed it :)

..and yes, /usr/local/share/gnucash/tip_of_the_day.list is present, but empty.
Comment 19 John Ralls 2017-05-26 17:46:41 UTC
Good that the crash is fixed. I'll get those changes pushed shortly. Look through your build and see if you can figure out why tip_of_the_day.list is empty. It's created by doc/Makefile.
Comment 20 John Ralls 2017-05-26 18:36:14 UTC
Fix is pushed, it'll be in the next release, thank you.
Comment 21 john.frankish@outlook.com 2017-05-27 05:12:05 UTC
About the only thing I could see in doc/Makefile was that nroff (from groff) was mentioned, but not present on my system - adding groff did not change anything however..
Comment 22 john.frankish@outlook.com 2017-05-27 06:01:03 UTC
Found it - the full fat version of cat is required.

gcc -flto -fuse-linker-plugin -mtune=generic -Os -pipe -E -P -x c -D'N_(x)=x' -o tip_of_the_day.list.tmp tip_of_the_day.list.in
cat -s tip_of_the_day.list.tmp | /usr/local/bin/sed -e 's/^ *"//' \
                       -e 's/"* *[|] */|/' \
                           -e 's:@-GNUCASH_LATEST_STABLE_SERIES-@:2.6:g' > tip_of_the_day.list
cat: invalid option -- 's'
BusyBox v1.25.1 (2017-03-14 16:33:32 UTC) multi-call binary.

Usage: cat [FILE]...

Concatenate FILEs and print them to stdout
rm -f tip_of_the_day.list.tmp
perl -pi.bak -e 's/" *$/\n/' tip_of_the_day.list
Comment 23 John Ralls 2018-06-29 23:57:04 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=783095. Please update any external references or bookmarks.