GNOME Bugzilla – Bug 783095
gnucash-2.6.16 segfaults on startup
Last modified: 2018-06-29 23:57:04 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
+ Trace 237508
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)"?
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?
I recompiled with "enable-debug", but it did not change the gdb output.
Did you remember to do a 'make clean' first?
I deleted the source folder and untarred it again :)
BTW, the first line of src/gnc-test-env.pl should be /usr/bin/env perl
(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.
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..
(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.
If I compile gnucash and glibc without "-g", I get this: (gdb)
+ Trace 237509
..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".
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.
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
+ Trace 237510
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
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.
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
+ Trace 237515
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
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.
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
+ Trace 237516
No arguments.
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?
That seems to have fixed it :) ..and yes, /usr/local/share/gnucash/tip_of_the_day.list is present, but empty.
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.
Fix is pushed, it'll be in the next release, thank you.
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..
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
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.