Front page | perl.perl5.porters |
Postings from June 2012
[perl #113586] [PATCH] 49c3f0d perlhacktips: add AddressSanitizer
Thread Previous
|
Thread Next
From:
rurban @ cpanel . net
Date:
June 11, 2012 08:44
Subject:
[perl #113586] [PATCH] 49c3f0d perlhacktips: add AddressSanitizer
Message ID:
rt-3.6.HEAD-5009-1339429422-1261.113586-75-0@perl.org
# New Ticket Created by rurban@cpanel.net
# Please include the string: [perl #113586]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=113586 >
This is a bug report for perl from rurban@cpanel.net,
generated with the help of perlbug 1.39 running under perl 5.17.1.
>From 49c3f0d246814a53fa4668445e143ebfd1dc3589 Mon Sep 17 00:00:00 2001
From: Reini Urban <rurban@x-ray.at>
Date: Mon, 11 Jun 2012 10:42:10 -0500
Subject: [PATCH] perlhacktips: add AddressSanitizer
---
pod/perlhacktips.pod | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 4 deletions(-)
diff --git a/pod/perlhacktips.pod b/pod/perlhacktips.pod
index bb995f3..092ac61 100644
--- a/pod/perlhacktips.pod
+++ b/pod/perlhacktips.pod
@@ -967,14 +967,16 @@ C<-std1> mode on.
=head1 MEMORY DEBUGGERS
-B<NOTE 1>: Running under memory debuggers such as Purify, valgrind, or
-Third Degree greatly slows down the execution: seconds become minutes,
+B<NOTE 1>: Running under older memory debuggers such as Purify, valgrind
+or Third Degree greatly slows down the execution: seconds become minutes,
minutes become hours. For example as of Perl 5.8.1, the
ext/Encode/t/Unicode.t takes extraordinarily long to complete under
e.g. Purify, Third Degree, and valgrind. Under valgrind it takes more
than six hours, even on a snappy computer. The said test must be doing
something that is quite unfriendly for memory debuggers. If you don't
feel like waiting, that you can simply kill away the perl process.
+Roughly valgrind slows down execution by factor 10, AddressSanitizer
+by factor 2.
B<NOTE 2>: To minimize the number of memory leak false alarms (see
L</PERL_DESTRUCT_LEVEL> for more information), you have to set the
@@ -1137,8 +1139,8 @@ finally report any memory problems.
=head2 valgrind
-The excellent valgrind tool can be used to find out both memory leaks
-and illegal memory accesses. As of version 3.3.0, Valgrind only
+The valgrind tool can be used to find out both memory leaks
+and illegal heap memory accesses. As of version 3.3.0, Valgrind only
supports Linux on x86, x86-64 and PowerPC and Darwin (OS X) on x86 and
x86-64). The special "test.valgrind" target can be used to run the
tests under valgrind. Found errors and memory leaks are logged in
@@ -1157,6 +1159,46 @@ To get valgrind and for more information see
http://valgrind.org/
+=head2 AddressSanitizer
+
+AddressSanitizer is a clang extension, included in clang since v3.1.
+It checks illegal heap pointers, global pointers, stack pointers and use
+after free, and is so fast that you can easily compile your debugging
+or optimized perl with it. It does not check memory leaks though.
+AddressSanitizer is available for linux, Mac OS X and soon on Windows.
+
+You should create the perl with AddressSanitizer using:
+
+ sh Configure -Dcc=clang -Accflags=-faddress-sanitizer \
+ -Aldflags=-faddress-sanitizer -Aldldflags=-shared\ -faddress-sanitizer
+
+where these arguments mean:
+
+=over 4
+
+=item * -Dcc=clang
+
+If clang is in your path, otherwise point to the path of the installed or temp.
+clang with AddressSanitizer enabled.
+
+=item * -Accflags=-faddress-sanitizer
+
+Instrument pointer accesses with AddressSanitizer.
+
+=item * -Aldflags=-faddress-sanitizer
+
+Link with AddressSanitizer.
+
+=item * -Alddlflags=-shared\ -faddress-sanitizer
+
+With a shared libperl.so, i.e. C<-Duseshrplib> is used, you must manually add
+C<-shared>.
+
+=back
+
+See L<http://code.google.com/p/address-sanitizer/wiki/AddressSanitizer>
+
+
=head1 PROFILING
Depending on your platform there are various ways of profiling Perl.
--
1.7.10
---
Flags:
category=docs
severity=medium
---
Site configuration information for perl 5.17.1:
Configured by rurban at Tue Jun 5 09:12:24 CDT 2012.
Summary of my perl5 (revision 5 version 17 subversion 1) configuration:
Derived from: 65bc432f8bb96d463b290c78d34350cb2d289cbc
Platform:
osname=linux, osvers=3.2.0-2-amd64, archname=x86_64-linux-thread-multi-debug@65bc432
uname='linux reini 3.2.0-2-amd64 #1 smp mon may 21 17:45:41 utc 2012 x86_64 gnulinux '
config_args='-de -Dusedevel -Dinstallman1dir=none -Dinstallman3dir=none -Dinstallsiteman1dir=none -Dinstallsiteman3dir=none -Dmksymlinks -DEBUGGING -Doptimize=-g3 -Duseithreads -Accflags='-msse4.2' -Accflags='-march=corei7' -Dcf_email='rurban@cpanel.net' -Dperladmin='rurban@cpanel.net' -Duseshrplib'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -msse4.2 -march=corei7 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-g3',
cppflags='-D_REENTRANT -D_GNU_SOURCE -msse4.2 -march=corei7 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.6.3', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.13'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/local/lib/perl5/5.17.1/x86_64-linux-thread-multi-debug@65bc432/CORE'
cccdlflags='-fPIC', lddlflags='-shared -g3 -L/usr/local/lib -fstack-protector'
Locally applied patches:
[cpan #72700] List::Util heap-overflow
---
@INC for perl 5.17.1:
/usr/local/lib/perl5/site_perl/5.17.1/x86_64-linux-thread-multi-debug@65bc432
/usr/local/lib/perl5/site_perl/5.17.1
/usr/local/lib/perl5/5.17.1/x86_64-linux-thread-multi-debug@65bc432
/usr/local/lib/perl5/5.17.1
/usr/local/lib/perl5/site_perl
.
---
Environment for perl 5.17.1:
HOME=/home/rurban
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/rurban/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Previous
|
Thread Next