Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 417419 - sys-devel/clang-3.1 should install address-sanitizer library files
Summary: sys-devel/clang-3.1 should install address-sanitizer library files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Bernard Cafarelli
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-24 21:01 UTC by Evan Teran
Modified: 2012-05-26 08:38 UTC (History)
3 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 Evan Teran 2012-05-24 21:01:33 UTC
clang 3.1 has a few new code analysis features, one of which is the "Address Sanitizer". http://llvm.org/releases/3.1/tools/clang/docs/AddressSanitizer.html

This feature (and possibly others) requires the installation of some support libraries to be linked into the program.

This fails because the ebuild does not install the libraries.

I don't recall if the clang ebuild uses cmake, but if it does, then it is an upstream problem: http://llvm.org/bugs/show_bug.cgi?id=12272

Reproducible: Always

Steps to Reproduce:
% cat example_UseAfterFree.cc
int main(int argc, char **argv) {
  int *array = new int[100];
  delete [] array;
  return array[argc];  // BOOM
}
% clang -O1 -g -faddress-sanitizer -fno-omit-frame-pointer example_UseAfterFree.cc
Actual Results:  
$ clang -O1 -g -faddress-sanitizer -fno-omit-frame-pointer example_UseAfterFree.cc
/usr/bin/x86_64-pc-linux-gnu-ld: cannot find /usr/bin/../lib/clang/3.1/lib/linux/libclang_rt.asan-x86_64.a: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected Results:  
% ./a.out 2> log
% projects/compiler-rt/lib/asan/scripts/asan_symbolize.py / < log | c++filt
==9442== ERROR: AddressSanitizer heap-use-after-free on address 0x7f7ddab8c084 at pc 0x403c8c bp 0x7fff87fb82d0 sp 0x7fff87fb82c8
READ of size 4 at 0x7f7ddab8c084 thread T0
    #0 0x403c8c in main example_UseAfterFree.cc:4
    #1 0x7f7ddabcac4d in __libc_start_main ??:0
0x7f7ddab8c084 is located 4 bytes inside of 400-byte region [0x7f7ddab8c080,0x7f7ddab8c210)
freed by thread T0 here:
    #0 0x404704 in operator delete[](void*) ??:0
    #1 0x403c53 in main example_UseAfterFree.cc:4
    #2 0x7f7ddabcac4d in __libc_start_main ??:0
previously allocated by thread T0 here:
    #0 0x404544 in operator new[](unsigned long) ??:0
    #1 0x403c43 in main example_UseAfterFree.cc:2
    #2 0x7f7ddabcac4d in __libc_start_main ??:0
==9442== ABORTING

$ emerge --info
Portage 2.2.0_alpha107 (default/linux/amd64/10.0, gcc-4.5.3, glibc-2.14.1-r3, 3.3.5-gentoo x86_64)
=================================================================
System uname: Linux-3.3.5-gentoo-x86_64-Intel-R-_Core-TM-_i7_CPU_M_640_@_2.80GHz-with-gentoo-2.1
Timestamp of tree: Thu, 24 May 2012 15:00:01 +0000
app-shells/bash:          4.2_p20
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.6.8, 2.7.3-r1, 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.10.3, 1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r2, 4.6.3
sys-devel/gcc-config:     1.5-r2
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.3 (virtual/os-headers)
sys-libs/glibc:           2.14.1-r3
Repositories: gentoo
Installed sets: 
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -fomit-frame-pointer -finline-functions -pipe -ggdb"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.3/ext-active/ /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 -O2 -fomit-frame-pointer -finline-functions -pipe -ggdb"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles news parallel-fetch parse-eapi-ebuild-head preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en en_US en_US.UTF-8"
MAKEOPTS="-j5"
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=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="64bit X acl acpi aio alsa amd64 apache2 apng aspell bash-completion berkdb bluetooth boost bzip2 c++0x cairo cddb cdr cli clucene cmake consolekit cracklib crypt css cups curl cxx dbus debugger declarative dell device-mapper dri dts dvd dvdr extra extras fastcgi ffmpeg flac fontconfig fortran gcj gd gdbm gif git gpm grammar graphite graphviz gtk gudev iconv icu innodb inotify ioctl ipv6 java java6 jpeg json kde kpathsea kqemu kvm lame laptop latex libnotify lto matroska minizip mmx mng modules mono mp3 mpeg mpi mplayer mudflap multilib mysql mysqli ncurses nls nptl nsplugin nvidia ogg openal opengl openmp openrc openssl openxml ovftool pam pcre pdf pdo perl plasma png policykit ppp pppd private-headers python qmake qt3support qt4 qtscript rdoc readline romio rss samba script sdl semantic-desktop session simplexml soap sockets sql sqlite sqlite3 sse sse2 sse3 sse4 sse4_1 sse4a ssl ssse3 static-analyzer subversion svg tcpd teamarena theora threads thumbnail tidy tools truetype udisks unicode usb valgrind virtuoso vmware-tools vorbis webgl webkit wicd wifi wxwidgets x264 xcomposite xine xinerama xml xorg xscreensaver xsl xvid zeroconf zlib" ALSA_CARDS="hda-intel" 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" 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" INPUT_DEVICES="keyboard mouse synaptics evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US en_US.UTF-8" PHP_TARGETS="php5-3" PYTHON_TARGETS="python3_2 python2_7" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby19" USERLAND="GNU" VIDEO_CARDS="nvidia vesa" 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"
USE_PYTHON="2.6 2.7"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-25 21:03:06 UTC
It doesn't use cmake; yet I'd appreciate any tips on enabling it with autoconf.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-26 07:41:31 UTC
Fixed in 3.1-r2 through adding compiler-rt.
Comment 3 Marcin Mirosław 2012-05-26 08:24:53 UTC
Is this (and others in 3.1-r1) fixes applied also to live ebuild?
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-26 08:30:40 UTC
(In reply to comment #3)
> Is this (and others in 3.1-r1) fixes applied also to live ebuild?

This one was in -9999 all the time, I think. I didn't move to -3.1 because at the time of ebuild writing upstream didn't release compiler-rt yet. For other fixes, you should talk to ryao.
Comment 5 Richard Yao (RETIRED) gentoo-dev 2012-05-26 08:38:26 UTC
(In reply to comment #3)
> Is this (and others in 3.1-r1) fixes applied also to live ebuild?

My position on 9999 ebuilds is that patches against them should be sent upstream rather than put into the tree, although the decision belongs to the sys-devel/clang maintainers.

Marcin, if you need these fixes to be applied now, you could create the /etc/portage/patches/sys-devel/clang-9999 directory and put copies of the 3.1 patches into it.