Bug 382771 - Segfault while loading project
Summary: Segfault while loading project
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: 5.1.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-27 00:58 UTC by Daniel Santos
Modified: 2017-08-08 06:43 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
backtrace -- stack overvflow? the address isn't < rsp but the stack trace goes on forever (191.42 KB, text/plain)
2017-07-27 00:58 UTC, Daniel Santos
Details
project file (53 bytes, text/plain)
2017-07-27 00:59 UTC, Daniel Santos
Details
.kdev4/gcc-git.kdev4 (12.72 KB, text/plain)
2017-07-27 01:00 UTC, Daniel Santos
Details
emerge --info on all deps of kdevelop (28.16 KB, text/plain)
2017-07-27 01:22 UTC, Daniel Santos
Details
unending stack trace (24.75 KB, application/gzip)
2017-07-30 05:32 UTC, Daniel Santos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Santos 2017-07-27 00:58:55 UTC
Created attachment 106878 [details]
backtrace -- stack overvflow?  the address isn't < rsp but the stack trace goes on forever

First off I'm sorry I didn't build my clang and llvm with debug symbols, I wasn't planning on having to debug anything with them!

Just loading the gcc project after having upgraded from KDevelop 4.  I've had a few bugs in kdev4 where you guys asked if I could try 5 and this is the reason I hadn't upgraded yet, because the last time it crashed right off as well.

Keep in mind that all of gcc's .c files are really c++ now, but I'm not digging into clang. :)

$ emerge --info dev-util/kdevelop dev-util/kdevplatform
!!! Repository 'rion' has sync-uri attribute, but is missing sync-type attribute                                                                                                                                                                 
Portage 2.3.6 (python 3.4.6-final-0, default/linux/amd64/13.0/desktop/plasma, gcc-5.4.0, glibc-2.24-r3, 4.1.15-gentoo-r1 x86_64)                                                                                                                 
=================================================================                                                                                                                                                                                
                         System Settings                                                                                                                                                                                                         
=================================================================                                                                                                                                                                                
System uname: Linux-4.1.15-gentoo-r1-x86_64-AMD_Phenom-tm-_9850_Quad-Core_Processor-with-gentoo-2.4.1                                                                                                                                            
KiB Mem:     8175900 total,   1966424 free                                                                                                                                                                                                       
KiB Swap:   16795944 total,  16795944 free                                                                                                                                                                                                       
Timestamp of repository gentoo: Wed, 26 Jul 2017 13:00:01 +0000                                                                                                                                                                                  
sh bash 4.4_p12                                                                                                                                                                                                                                  
ld GNU ld (Gentoo 2.28 p1.2) 2.28                                                                                                                                                                                                                
distcc 3.2rc1 x86_64-pc-linux-gnu [enabled]                                                                                                                                                                                                      
ccache version 3.3.4 [enabled]                                                                                                                                                                                                                   
app-shells/bash:          4.4_p12::gentoo                                                                                                                                                                                                        
dev-java/java-config:     2.2.0-r3::gentoo                                                                                                                                                                                                       
dev-lang/perl:            5.24.2::gentoo                                                                                                                                                                                                         
dev-lang/python:          2.7.13::gentoo, 3.4.6::gentoo
dev-util/ccache:          3.3.4::gentoo
dev-util/cmake:           3.9.0::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.4.1::gentoo
sys-apps/openrc:          0.28::gentoo
sys-apps/sandbox:         2.10-r4::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.64::gentoo, 2.69-r3::gentoo
sys-devel/automake:       1.11.6-r2::gentoo, 1.12.6-r1::gentoo, 1.13.4-r1::gentoo, 1.14.1-r1::gentoo, 1.15.1::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo, 2.27-r1::gentoo, 2.28-r2::gentoo
sys-devel/gcc:            4.9.4::gentoo, 5.4.0-r3::gentoo, 6.3.0::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r4::gentoo
sys-devel/make:           4.2.1-r1::gentoo
sys-kernel/linux-headers: 4.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.24-r3::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

loudmouth-local
    location: /usr/local/portage
    masters: gentoo
    priority: 0

gamerlay
    location: /var/lib/layman/gamerlay
    masters: gentoo
    priority: 50

pentoo
    location: /var/lib/layman/pentoo
    masters: gentoo
    priority: 50

rion
    location: /var/lib/layman/rion
    sync-uri: https://github.com/rion-overlay/rion-overlay.git
    masters: gentoo
    priority: 50

sunrise
    location: /var/lib/layman/sunrise
    masters: gentoo
    priority: 50

zugaina
    location: /var/lib/layman/zugaina
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -ggdb -march=amdfam10 -msahf -mpopcnt -mlzcnt -mtune=amdfam10 --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -ggdb -march=amdfam10 -msahf -mpopcnt -mlzcnt -mtune=amdfam10 --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="-j3 --load-average=8 --with-bdeps=y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg candy ccache cgroup compress-build-logs config-protect-if-modified distcc distlocks ebuild-locks fixlafiles installsources merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms split-elog split-log splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://gentoo.mirrors.easynews.com/linux/gentoo/ http://gentoo.cites.uiuc.edu/pub/gentoo/ http://www.gtlib.gatech.edu/pub/gentoo"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j18 --load-average=6"
PKGDIR="/usr/portage/packages"
PORTAGE_COMPRESS="pxz"
PORTAGE_COMPRESS_FLAGS="-9e -T4"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/tmp"
USE="7zip X a52 aac aacplus aacs acl acpi aio alsa amd64 apache2 autotools bazaar berkdb bindist bluetooth bluray branding bzip2 cairo cdda cddb cdio cdr celt cg clang cli cmake consolekit cracklib crypt cups cvs cxx dbus declarative designer development device-mapper dirac directfb dot dri dts dvd dvdr emboss encode exif extraengine faac fam ffmpeg fftw firefox flac fluidsynth fortran frei0r fuse gcj gdbm geoip gif git glamor glew glut gme gnome-keyring gnutls gphoto2 gpm graphviz gsm gstreamer gtk gtk3 hardened highlight iconv id3tag ipv6 java jpeg jpeg2k kate kde kdrive kipi kwallet ladspa lame lcms ldap lensfun libass libcaca libnotify libsamplerate libv4l lto lua lz4 lzma lzo mad matroska md5sum mercurial midi mmx mmxext mng modules mp3 mp4 mpeg mtp mudflap multicall multilib multitarget musepack natspec ncurses networkmanager nls nptl nsplugin objc objc++ objc-gc ogg okteta omr openal opencl openexr opengl openmp opus pam pango pch pcre pdf perl phonon plasma playlist png policykit ppds projectm python qemu qml qt3support qt4 qt5 qthelp quvi rar raw readline reviewboard rfc3779 sasl sbsms scanner schroedinger sdl seccomp semantic-desktop session sid smp soundtouch speex spell spice sqlite sqlite3 sse sse2 sse3 ssh ssl startup-notification static-libs subversion svg syslog systemtap taglib tcpd theora threads thumbnail tiff tk tools tremor truetype twolame udev udisks unicode upnp upnp-av upower usb usbredir utils v4l vaapi valgrind vcdx vde vdpau vhost-net vim-syntax vlc vorbis vpx vte wavpack webkit webp widgets wifi wxwidgets x264 x265 xattr xcb xcomposite xine xinerama xml xpm xrandr xscreensaver xv xvid xvmc zeroconf zlib zvbi" ABI_X86="64 32" ALSA_CARDS="hdsp emu10k1 hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="keyboard mouse joystick evdev wacom vmmouse" KERNEL="linux" L10N="en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en_US" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" QEMU_SOFTMMU_TARGETS="aarch64 arm armeb i386 m68k mips mips64 mips64el mipsel mipsn32 mipsn32el ppc ppc64 ppc64abi32 ppc64le x86_64" QEMU_USER_TARGETS="aarch64 arm armeb i386 m68k mips mips64 mips64el mipsel mipsn32 mipsn32el ppc ppc64 ppc64abi32 ppc64le x86_64" RUBY_TARGETS="ruby19 ruby20 ruby22 ruby23 ruby24" USERLAND="GNU" VIDEO_CARDS="nvidia radeon qxl vmware" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

dev-util/kdevelop-5.1.1::gentoo was built with the following:
USE="handbook ninja plasma qmake qthelp -debug -gdbui -okteta -test" ABI_X86="(64)"


dev-util/kdevplatform-5.1.1::gentoo was built with the following:
USE="cvs reviewboard subversion welcomepage -debug -test" ABI_X86="(64)"
Comment 1 Daniel Santos 2017-07-27 00:59:41 UTC
Created attachment 106879 [details]
project file
Comment 2 Daniel Santos 2017-07-27 01:00:30 UTC
Created attachment 106880 [details]
.kdev4/gcc-git.kdev4
Comment 3 Daniel Santos 2017-07-27 01:22:47 UTC
Created attachment 106881 [details]
emerge --info on all deps of kdevelop

If you need to know anything else about my environment, I've included the emerge --info for all of kdeveop's dependencies via:

emerge --info dev-util/kdevelop $(for f in $(ldd /usr/bin/kdevelop | awk '{print $3}'); do qfile $f; done | awk '{print $1}' | sort -u)
Comment 4 Kevin Funk 2017-07-27 06:19:13 UTC
I can't find a bug report with a similar backtrace from Upstream.

Could you provide a bit more information?
- Which project are you working on? Can you share?
- Could you try to figure out which file KDevelop crashes on? The last lines of the debug output of kdevelop should tell you what it is currently parsing.
Comment 5 Daniel Santos 2017-07-28 01:43:46 UTC
(In reply to Kevin Funk from comment #4)
> I can't find a bug report with a similar backtrace from Upstream.
> 
> Could you provide a bit more information?
> - Which project are you working on? Can you share?
This is just the current HEAD of gcc: https://github.com/gcc-mirror/gcc

> - Could you try to figure out which file KDevelop crashes on? The last lines
> of the debug output of kdevelop should tell you what it is currently parsing.

I didn't see output in stdout or stderr, do you mean in the backtrace?  I admit I was surprised by the length of that and never got to the end of it.  The file gcc-git.kdev4 has the list of files I excluded from the project so that the parser would only parse libs and archs that I was working on.  It's running if I disable the parser, but KDevelop's parsing is something that I've always appreciated, even if it crashes sometimes.

Please let me know if you are unable to reproduce and I'll try again.  I have since rebuilt llvm and clang with -ggdb.
Comment 6 Daniel Santos 2017-07-30 05:29:16 UTC
I guess I'm supposed to repoen the bug after posting the info?
Comment 7 Daniel Santos 2017-07-30 05:32:03 UTC
Created attachment 106964 [details]
unending stack trace

(In reply to Kevin Funk from comment #4)
> - Could you try to figure out which file KDevelop crashes on? The last lines
> of the debug output of kdevelop should tell you what it is currently parsing.

The stacktrace is unending (I finally interrupted it after 13000 frames that kept repeating)
Comment 8 Daniel Santos 2017-08-05 23:09:44 UTC
Ping.

(In reply to Kevin Funk from comment #4)
> - Could you try to figure out which file KDevelop crashes on? The last lines
> of the debug output of kdevelop should tell you what it is currently parsing.

By the way, I have not seen KDevelop give "debug output" that specifies what file it's parsing.  I have build it with USE=debug (on Gentoo), so can you please be more specific about what mechanism is required to output this?
Comment 9 Kevin Funk 2017-08-07 08:04:35 UTC
Please try starting KDevelop in the terminal like this:
  QT_LOGGING_RULES="kdev*=true" kdevelop --ps
Comment 10 Daniel Santos 2017-08-07 09:17:18 UTC
(In reply to Kevin Funk from comment #9)
> Please try starting KDevelop in the terminal like this:
>   QT_LOGGING_RULES="kdev*=true" kdevelop --ps


Interesting, I tried running

QT_LOGGING_RULES="kdev*=true" gdb --args kdevelop --ps

and it didn't crash where it had before, but while parsing files it decided that it needed 18.5GiB of memory and I had to kill it.  I'm running it now w/o gdb and I changed the number of parsing threads to 1 so as to be more certain of which file blew up and it's not failing yet nor eating much memory.  I'll try this again tomorrow w/o the QT_LOGGING_RULES just to verify that I can still produce the error.
Comment 11 Daniel Santos 2017-08-07 11:27:28 UTC
Well here you go, this is at least one parse fail for upstream.  This was w/o gdb so I don't have a backtrace, but I'll guess that clang had a stack overflow like gcc did prior to fixing it.  I'm still not certain that this was the original failure, so I'll play more with it later.

kdevplatform.language: creating parse-job "/home/daniel/proj/sys/gcc/git/gcc/testsuite/g++.dg/parse/stack1.C" new count of active parse-jobs: 1
Segmentation fault

$ cat /home/daniel/proj/sys/gcc/git/gcc/testsuite/g++.dg/parse/stack1.C
/* PR c/2161: parser stack overflow.  */
/* { dg-do compile } */

#define ONE     else if (0) { }
#define TEN     ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE
#define HUN     TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
#define THOU    HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN

void foo()
{
  if (0) { }
  /* 11,000 else if's.  */
  THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU
}
Comment 12 Kevin Funk 2017-08-07 11:36:05 UTC
> "/home/daniel/proj/sys/gcc/git/gcc/testsuite/g++.dg/parse/stack1.C"

Yes, I feared something like this. KDevelop is attempting to parse one of GCC's unit tests. These are usually regressions tests for very bad compiler bugs. The libclang version you're using is probably not protected against this particular issue yet and will crash.

Note this is a pretty special issue, when working on any compiler code base. There are tons of source files for testing in them which will make any C++ parse go mad (think of "torture tests", etc.).
Comment 13 Kevin Funk 2017-08-07 11:36:17 UTC
The only sane way to fix this is to ignore the whole testsuite/ folder by placing an empty .kdev_ignore in it (this will make KDevelop's background parser ignore everything below it).

Please try and report back!
Comment 14 Daniel Santos 2017-08-08 01:37:21 UTC
(In reply to Kevin Funk from comment #13)
> The only sane way to fix this is to ignore the whole testsuite/ folder by
> placing an empty .kdev_ignore in it (this will make KDevelop's background
> parser ignore everything below it).
> 
> Please try and report back!

Yes, that makes plenty of sense.  For clang, I suppose it's a nice opportunity to leverage work done to produce tests for gcc.  And quite frankly, having testsuite code parsed is not very valuable at all.  Getting good parsing of the middle-end is, especially for somebody like me with no experience with data flow analysis, interprocedural constant propagation and such.  I don't have this properly parsed yet, because of the quirk that gcc was converted to C++ a few years ago, but all of the file still end in .c.  I believe I've found the fix in KDevelop for that, but I need to rebuild gcc (for build tree headers) and reparse.  When I'm done with this, perhaps I should write a blog post about using KDevelop to work on gcc.  

But as for this bug, I still want to try to reproduce the crash I was having earlier to make sure that this is the full and correct work-around.  I'll try to get back with you as soon as possible.

Thanks!
Daniel
Comment 15 Kevin Funk 2017-08-08 06:43:25 UTC
> When I'm done with this, perhaps I should write a blog post about using KDevelop to work on gcc.  

That'd be very much appreciated, make sure to notify us on e.g. kdevelop@kde.org or #kdevelop on Freenode. Thanks a lot!