Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 427206 - sys-devel/llvm-3.1-r2 leads to segmentation faults in sys-devel/clang
Summary: sys-devel/llvm-3.1-r2 leads to segmentation faults in sys-devel/clang
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal critical with 1 vote (vote)
Assignee: Michał Górny
URL:
Whiteboard:
Keywords: PMASKED
Depends on:
Blocks: systemwide-clang
  Show dependency tree
 
Reported: 2012-07-19 11:26 UTC by Severin Strobl
Modified: 2012-09-06 11:42 UTC (History)
9 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Severin Strobl 2012-07-19 11:26:33 UTC
The changes introduced in sys-devel/llvm-3.1-r2 lead to segfaults in sys-devel/clang. The only obvious change in sys-devel/llvm-3.1-r2 compared to the previous -r1 was the inclusion of two patches related to bug #425688. I have no idea how these OpenCL-related changes affect the general behaviour of llvm. To verify the source for this bug, I modified the ebuild for sys-devel/llvm-3.1-r2 to not include these patches for r600. This indeed fixed the problem, sys-devel/clang works as expected again. The error returned by sys-devel/clang is rather unspecific, I'll try to come up with a small test case that demonstrates the problem.

Reproducible: Always

Actual Results:  
0  libLLVM-3.1.so  0x00007fb58e23b3ff
1  libLLVM-3.1.so  0x00007fb58e23b7c9
2  libpthread.so.0 0x00007fb58dd243e0
3  libLLVM-3.1.so  0x00007fb58e1acb3d
4  libLLVM-3.1.so  0x00007fb58e1b192c
5  libLLVM-3.1.so  0x00007fb58e1b3e48
6  libLLVM-3.1.so  0x00007fb58e75626c llvm::MPPassManager::runOnModule(llvm::Module&) + 508
7  libLLVM-3.1.so  0x00007fb58e756368 llvm::PassManagerImpl::run(llvm::Module&) + 136
8  clang           0x00000000006a4203 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 2067
9  clang           0x00000000006a2027
10 clang           0x00000000007fc55f clang::ParseAST(clang::Sema&, bool, bool) + 415
11 clang           0x00000000006a0f63 clang::CodeGenAction::ExecuteAction() + 51
12 clang           0x0000000000561d92 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 274
13 clang           0x0000000000547928 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1240
14 clang           0x000000000053d61a cc1_main(char const**, char const**, char const*, void*) + 6442
15 clang           0x00000000005465b9 main + 6889
16 libc.so.6       0x00007fb58d69f2ad __libc_start_main + 253
17 clang           0x000000000053b319
Stack dump:
0.	Program arguments: /usr/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name QARecord.cpp -pic-level 2 -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.21.1 -momit-leaf-frame-pointer -g -coverage-file build-dir/clang-linux-3.1/release/debug-symbols-on/src/exodusII/QARecord.o -resource-dir /usr/bin/../lib/clang/3.1 -D NDEBUG -I . -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4 -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/x86_64-pc-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/backward -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wall -Weffc++ -Werror -Wshadow -Wno-inline -Wall -Wall -Weffc++ -Werror -Wshadow -pedantic -std=c++98 -fdeprecated-macro -fdebug-compilation-dir /home/severin/coding/exodusII++ -ferror-limit 19 -fmessage-length 0 -mstackrealign -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o build-dir/clang-linux-3.1/release/debug-symbols-on/src/exodusII/QARecord.o -x c++ src/exodusII/QARecord.cpp 
1.	<eof> parser at end of file
2.	Per-module optimization passes
3.	Running pass 'Interprocedural Sparse Conditional Constant Propagation' on module 'src/exodusII/QARecord.cpp'.
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://llvm.org/bugs/ and include command line arguments and all diagnostic information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/QARecord-4WUiKb.ii
clang: note: diagnostic msg: /tmp/QARecord-4WUiKb.sh


Portage 2.1.10.65 (default/linux/amd64/10.0, gcc-4.5.3, glibc-2.14.1-r3, 3.4.4-gentoo x86_64)
=================================================================
System uname: Linux-3.4.4-gentoo-x86_64-Intel-R-_Core-TM-_i5_CPU_750_@_2.67GHz-with-gentoo-2.1
Timestamp of tree: Thu, 19 Jul 2012 09:30:01 +0000
app-shells/bash:          4.2_p20
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.3-r2, 3.1.5, 3.2.3
dev-util/cmake:           2.8.7-r5
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.9.6-r3, 1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r2
sys-devel/gcc-config:     1.6
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.4-r1 (virtual/os-headers)
sys-libs/glibc:           2.14.1-r3
Repositories: gentoo science xarthisius hasufell jxh x-portage
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA @FSF-APPROVED dlj-1.1 PUEL Oracle-BCLA-JavaSE AdobeFlash-10.3 Intel-SDP"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O3 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/env.d/java/ /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="-march=native -O3 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles metadata-transfer news parallel-fetch parse-eapi-ebuild-head protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en de"
MAKEOPTS="-j5 -l5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/science /var/lib/layman/xarthisius /var/lib/layman/hasufell /var/lib/layman/jxh /usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext X a52 aac acl acpi aiglx alsa amd64 avi bash-completion berkdb boost branding bzip2 cairo cdda cdparanoia cdr cli consolekit cracklib crypt cups cxx dbus dri dvd dvdr dvdread encode eselect exif ffmpeg flac fortran ftp gdbm gimpprint gmp gnome gnome-keyring gnutls gpm gstreamer gtk gtk2 hal iconv icu jabber java jpeg kpathsea ldap lm_sensors mad mmx mmxext mng modules mp3 mpi mplayer mudflap multilib ncurses nls nptl nptlonly nsplugin ogg oggvorbis opengl openmp pam pcre png postscript pppd python qt3support readline recode rtc sasl sdl session spell sqlite sse sse2 ssl ssse3 subtitles subversion svg symlink tcpd threads tiff truetype unicode usb vim-syntax vorbis x264 xft xinerama xml xmms xorg xulrunner xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="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" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" DRACUT_MODULES="caps crypt crypt-gpg lvm mdraid syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en de" PHP_TARGETS="php5-3" PYTHON_TARGETS="python3_2 python2_7" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="radeon nvidia" 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:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Marcus Bannerman 2012-07-19 12:20:09 UTC
Just confirming that I have trouble with -r2 as well. I have similar stack dumps from the compiler (see below) and downgrading to -r1 removed the issues. No minimal example available, sorry, but it does fail while compiling boost so its not just my dodgy code :-)

libLLVM-3.1.so  0x00007f48c6dd7bef
1  libLLVM-3.1.so  0x00007f48c6dd81ba
2  libpthread.so.0 0x00007f48c68ae420
3  libLLVM-3.1.so  0x00007f48c6d4dc6d
4  libLLVM-3.1.so  0x00007f48c6d52b2c
5  libLLVM-3.1.so  0x00007f48c6d54e3a
6  libLLVM-3.1.so  0x00007f48c72dc32c llvm::MPPassManager::runOnModule(llvm::Module&) + 508
7  libLLVM-3.1.so  0x00007f48c72dc40f llvm::PassManagerImpl::run(llvm::Module&) + 111
8  clang           0x00000000006a7d9b clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 2075
9  clang           0x00000000006a5c27
10 clang           0x00000000007f1dff clang::ParseAST(clang::Sema&, bool, bool) + 415
11 clang           0x00000000006a4b93 clang::CodeGenAction::ExecuteAction() + 51
12 clang           0x000000000056c321 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 273
13 clang           0x0000000000552a18 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1240
14 clang           0x00000000005493ea cc1_main(char const**, char const**, char const*, void*) + 6378
15 clang           0x00000000005518cc main + 5900
16 libc.so.6       0x00007f48c62272ad __libc_start_main + 253
17 clang           0x0000000000547959
Comment 2 Ambroz Bizjak 2012-07-19 16:08:45 UTC
I'm also having issues with llvm-3.1-r2. It doesn't crash, but it makes clang miscompile some software of mine ( http://code.google.com/p/badvpn/wiki/NCD ). My interpreter segfaults trying to execute any script. Reverting to llvm-3.1-r1 fixes it. I've also tried recompiling clang after upgrading to llvm-3.1-r2, but it didn't help.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-07-20 20:36:52 UTC
What are your USE? Could you post the 'emerge -pv llvm clang'?
Comment 4 Severin Strobl 2012-07-20 21:07:05 UTC
Sure, here we go:

sys-devel/llvm-3.1-r2  USE="libffi vim-syntax -debug -gold -multitarget -ocaml -test -udis86"

sys-devel/clang-3.1-r5  USE="static-analyzer -debug -multitarget -test"
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-07-20 21:23:40 UTC
(In reply to comment #4)
> Sure, here we go:
> 
> sys-devel/llvm-3.1-r2  USE="libffi vim-syntax -debug -gold -multitarget
> -ocaml -test -udis86"
> 
> sys-devel/clang-3.1-r5  USE="static-analyzer -debug -multitarget -test"

Ok, are the others reproducing it using USE=-multitarget? Maybe that's because we didn't notice...
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-07-20 21:24:03 UTC
s/because/why/, it's too late for me...
Comment 7 Ambroz Bizjak 2012-07-20 22:47:52 UTC
I'm using ~amd64; here are the use flags:

r   sys-devel/llvm:0::ambro 3.1-r1 to ::installed replacing 3.1-r1
    -debug gold libffi -multitarget -ocaml -udis86 -vim-syntax (-test) build_options: symbols=split -optional_tests -trace -preserve_work
    Reasons: target, sys-devel/clang
r   sys-devel/clang:0::gentoo 3.1-r5 to ::installed replacing 3.1-r5
    -debug -multitarget static-analyzer (-test) build_options: symbols=split -optional_tests -trace -preserve_work
    Reasons: target

cave info:

Package Manager Information:
    Package Name              paludis
    Package Version           0.76.0
    Build Date                2012-06-28T12:05:20+0200
    Built with CXX            x86_64-pc-linux-gnu-g++ 4.7.1
    Built with CXXFLAGS        -O2 -march=core2 -pipe -pedantic
    Built with LDFLAGS        -Wl,-O1 -Wl,--as-needed 

Environment Information:
    Format                    paludis
    Config dir                /etc/paludis
    Root                      /
    System Root               /
    World file                /var/db/pkg/world

Repository gentoo:
    format                    e
    location                  /usr/portage
    builddir                  /var/tmp/paludis
    cache                     /usr/portage/metadata/md5-cache
    distdir                   /var/paludis/distfiles
    eapi_when_unknown         0
    eapi_when_unspecified     0
    eclassdirs                /usr/portage/eclass
    layout                    traditional
    manifest_hashes           SHA256 SHA512 WHIRLPOOL
    names_cache               /var/cache/paludis/names
    newsdir                   /usr/portage/metadata/news
    profile_eapi_when_unspecified 0
    profile_layout            traditional
    profiles                  /usr/portage/profiles/default/linux/amd64/10.0/desktop  /etc/paludis/profile
    securitydir               /usr/portage/metadata/glsa
    setsdir                   /usr/portage/sets
    sync                      gentoo://http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2
    sync_options              
    thin_manifests            false
    use_manifest              use
    write_cache               /var/empty
    Package information
        app-shells/bash       4.2_p36
        dev-java/java-config  (none)
        dev-lang/python       2.6.8 2.7.3-r2 3.1.5 3.2.3-r1
        dev-util/ccache       (none)
        dev-util/cmake        2.8.8-r3
        dev-util/pkgconfig    0.27
        sys-apps/baselayout   2.1-r1
        sys-apps/openrc       0.10.5
        sys-apps/sandbox      2.6
        sys-devel/autoconf    2.13 2.69
        sys-devel/automake    1.11.6 1.12.2 1.9.6-r3
        sys-devel/binutils    2.22-r1
        sys-devel/gcc         4.4.7 4.5.4 4.6.3 4.7.1
        sys-devel/gcc-config  1.7.3
        sys-devel/libtool     2.4.2
        sys-devel/make        3.82-r3
        sys-freebsd/freebsd-lib (none)
        sys-kernel/linux-headers 3.4-r1
        sys-libs/glibc        2.14.1-r3
        sys-libs/uclibc       (none)
Comment 8 Matt Turner gentoo-dev 2012-07-21 17:24:22 UTC
I hit this too with 3.1-r2.
Comment 9 Richard Yao (RETIRED) gentoo-dev 2012-07-21 19:00:34 UTC
Would someone provide a simple set of instructions to use to reproduce this?

Ideally, I would like something like `env CC=clang CXX=clang++ emerge --oneshot =category/name-version` that I could use to reproduce it.
Comment 10 Matt Turner gentoo-dev 2012-07-21 19:33:18 UTC
CC=clang CXX=clang++ ebuild /usr/portage/media-libs/mesa/mesa-8.0.3.ebuild compile
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-07-21 21:50:26 UTC
(In reply to comment #10)
> CC=clang CXX=clang++ ebuild /usr/portage/media-libs/mesa/mesa-8.0.3.ebuild
> compile

I can reproduce that with patched llvm and older clang. Did anyone try newer clang and older llvm?
Comment 12 Severin Strobl 2012-07-21 21:57:40 UTC
Yes tried that, sys-devel/clang-3.1-r5 in combination with sys-devel/llvm-3.1-r1 did not produce any segfaults in my case.
Comment 13 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-07-21 22:29:00 UTC
I've masked the relevant versions. Alexxy, would you please take this bugreport to the patch authors?
Comment 14 Richard Yao (RETIRED) gentoo-dev 2012-07-21 23:02:54 UTC
(In reply to comment #12)
> Yes tried that, sys-devel/clang-3.1-r5 in combination with
> sys-devel/llvm-3.1-r1 did not produce any segfaults in my case.

This is my experience too. I looked through the patches that were introduced in sys-devel/llvm-3.1-r2 and I did not see any obvious cause. We probably should contact the author to have him look at this.
Comment 15 Arseny Solokha 2012-08-01 02:42:57 UTC
sys-devel/clang-3.1-r4 w/ sys-devel/llvm-3.1-r1 compiles the following minimal example just fine but fails w/ the backtrace in static analyzer mode:

% cat test1.c
#define NULL ((void *)0)


static void
bar(void)
{
  int rv;
  if (0 != rv)
    ;
}

static void
foo(void)
{
  bar();
}

% clang -c test1.c

% clang --analyze test1.c           
0  libLLVM-3.1.so  0x00007fb79a592fdf
1  libLLVM-3.1.so  0x00007fb79a593449
2  libpthread.so.0 0x00007fb79a07fce0
3  clang           0x0000000000bd49a0
4  clang           0x0000000000bde94c clang::ento::GRBugReporter::GeneratePathDiagnostic(clang::ento::PathDiagnostic&, llvm::SmallVectorImpl<clang::ento::BugReport*>&) + 12364
5  clang           0x0000000000bdb09b clang::ento::BugReporter::FlushReport(clang::ento::BugReportEquivClass&) + 3627
6  clang           0x0000000000bdf118 clang::ento::BugReporter::FlushReports() + 1112
7  clang           0x0000000000ace84d
8  clang           0x0000000000acf212
9  clang           0x0000000000ad62e9
10 clang           0x00000000007bd31d clang::ParseAST(clang::Sema&, bool, bool) + 461
11 clang           0x000000000055e6a3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 259
12 clang           0x0000000000547942 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1010
13 clang           0x000000000053eab5 cc1_main(char const**, char const**, char const*, void*) + 8853
14 clang           0x0000000000546b7f main + 7151
15 libc.so.6       0x00007fb7999e53ed __libc_start_main + 237
16 clang           0x000000000053c699
Stack dump:
0.	Program arguments: /usr/bin/clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -main-file-name test1.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-ipa=inlining -analyzer-checker=core -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-output plist -w -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.22 -momit-leaf-frame-pointer -resource-dir /usr/bin/../lib/clang/3.1 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 136 -mstackrealign -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o test.plist -x c test1.c 
1.	<eof> parser at end of file
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://llvm.org/bugs/ and include command line arguments and all diagnostic information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-hrryVh.i
clang: note: diagnostic msg: /tmp/test-hrryVh.sh
zsh: exit 254   clang --analyze test1.c

Slightly modifying the testcase I've been also able to get the different backtrace:

% cat test2.c
#define NULL ((void *)0)

typedef unsigned long int pthread_t;

int pthread_join(pthread_t thread, void **retval);


void
durr(pthread_t t)
{
  int rv;
  void *trv = NULL;
  if (0 != (rv = pthread_join(t, &trv)))
    ;
  if (0 != rv && NULL != trv)
    ;
}

void
hurr(pthread_t t)
{
  durr(t);
}

% clang --analyze test2.c
0  libLLVM-3.1.so  0x00007f3fdf6d9fdf
1  libLLVM-3.1.so  0x00007f3fdf6da449
2  libpthread.so.0 0x00007f3fdf1c6ce0
3  clang           0x0000000000c18bc7 clang::ento::ExprEngine::processCallExit(clang::ento::ExplodedNode*) + 1511
4  clang           0x0000000000bf6051 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) + 465
5  clang           0x0000000000bf6122 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) + 194
6  clang           0x0000000000ace816
7  clang           0x0000000000acf212
8  clang           0x0000000000ad62e9
9  clang           0x00000000007bd31d clang::ParseAST(clang::Sema&, bool, bool) + 461
10 clang           0x000000000055e6a3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 259
11 clang           0x0000000000547942 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1010
12 clang           0x000000000053eab5 cc1_main(char const**, char const**, char const*, void*) + 8853
13 clang           0x0000000000546b7f main + 7151
14 libc.so.6       0x00007f3fdeb2c3ed __libc_start_main + 237
15 clang           0x000000000053c699

Not sure though whether these two are related to the original issue.
Comment 16 Arseny Solokha 2012-08-01 02:50:42 UTC
Well, the my issue is apparently unrelated: http://llvm.org/bugs/show_bug.cgi?id=12945
Comment 17 Richard Yao (RETIRED) gentoo-dev 2012-08-01 17:11:46 UTC
(In reply to comment #16)
> Well, the my issue is apparently unrelated:
> http://llvm.org/bugs/show_bug.cgi?id=12945

Would you file a separate bug report for this issue?
Comment 18 Bernard Cafarelli gentoo-dev 2012-08-22 09:31:08 UTC
ryao, you had a good idea :)

After applying the cl-patches from llvm to clang-3.1-r5, CC=clang CXX=clang++ ebuild /usr/portage/media-libs/mesa/mesa-8.0.3.ebuild compile worked.

This may need some further testing, but this sounds like we found the root cause.
Comment 19 Bernard Cafarelli gentoo-dev 2012-08-30 09:43:03 UTC
I updated clang-3.1-r5 ebuild to also apply llvm cl-patches, if someone can confirm llvm-3.1-r2/clang-3.1-r5 now works fine, I'll drop the mask and mark this as resolved :)
Comment 20 Severin Strobl 2012-09-05 14:47:32 UTC
(In reply to comment #19)
> I updated clang-3.1-r5 ebuild to also apply llvm cl-patches, if someone can
> confirm llvm-3.1-r2/clang-3.1-r5 now works fine, I'll drop the mask and mark
> this as resolved :)

I can confirm that the combination of sys-devel/llvm-3.1-r2 and sys-devel/clang-3.1-r5 works as expected for my test case. Anybody still encountering any problems with the updated version?
Comment 21 Matt Turner gentoo-dev 2012-09-05 22:10:06 UTC
I can confirm that clang-3.1-r5 with llvm-3.1-r2 fix the problem. Thanks!
Comment 22 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-09-06 07:49:33 UTC
Unmasked then.