From simon.urbanek at r-project.org  Fri Apr 19 21:36:28 2013
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Fri, 19 Apr 2013 15:36:28 -0400
Subject: [Rd] Linux distribution with gcc 4.8  and AddressSanitizer ?
In-Reply-To: <51718AAE.9080108@stats.ox.ac.uk>
References: <5170135E.7090309@tu-dresden.de> <1665624.PmurviQP17@ulysses>
	<51717D68.4050400@tu-dresden.de> <51718AAE.9080108@stats.ox.ac.uk>
Message-ID: <6FEF5F44-C3E9-488C-BA25-AFD595F3AAB5@r-project.org>


On Apr 19, 2013, at 2:19 PM, Prof Brian Ripley wrote:

> On 19/04/2013 18:22, Thomas Petzoldt wrote:
>> On 18.04.2013 18:05, Jos? Matos wrote:
>>> On Thursday 18 April 2013 17:38:06 Thomas Petzoldt wrote:
>>>> Dear R developers,
>>>> 
>>>> I've got an information from Prof. Ripley regarding a bug found
>>>> with AdressSanitizer in one of our packages. It is now fixed, thank
>>>> you for this information.
>>>> 
>>>> Now, I would like to run AddressSanitizer myself before submitting
>>>> the patched package to CRAN.
>>>> 
>>>> Is there a recommendation of a suitable Linux distribution with gcc
>>>> 4.8, ideally an ISO image or (even better) a virtual appliance for
>>>> VMware or VirtalBox? My Debian Wheezy machines have only 4.7.2.
>>>> 
>>>> Thank you
>>>> 
>>>> Thomas Petzoldt
>>> 
>>> I am not sure about all the requisites above (regarding the virtual
>>> appliances although I know that they are available) but Fedora 19
>>> (Alpha) that will be released today has gcc 4.8.
>>> 
>>> Even although it has the Alpha moniker, and the corresponding stage,
>>> it is relatively stable and thus suitable for your requirements.
>>> 
>>> Regards,
>>> 
>> 
>> Thank you for the hint to use Fedora 19 Alpha. I have it now running,
>> together with R 3.0.0. and gcc 4.8.0 20120412 (Red Hat 4.8.0-2).
>> 
>> Compilation and installation of packages (without ASAN) workes out of
>> the box.
>> 
>> Then I've set:
>> 
>> export PKG_CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
>> 
>> ... and compilation runs and I see that gcc uses the flags, but package
>> installation still fails:
>> 
>> ** testing if installed package can be loaded
>> Error in dyn.load(file, DLLpath = DLLpath, ...) :
>>   unable to load shared object
>> '/home/user/packages/deSolve.Rcheck/deSolve/libs/deSolve.so':
>>   /home/user/packages/deSolve.Rcheck/deSolve/libs/deSolve.so: undefined
>> symbol: __asan_report_load8
>> Error: loading failed
>> Execution halted
>> ERROR: loading failed
>> 
>> 
>> I see that the address sanitizer cannot work yet (__asan_report_load8)
>> and that I missed something important, but what?
> 
> The manual said
> 
> 'It requires code to have been compiled and linked with -fsanitize=address'
> 
> I don't see that you linked with it ...
> 
> I have (in ~/.R/Makevars)
> 
> CC="gcc -std=gnu99 -fsanitize=address -fno-omit-frame-pointer"
> 
> and similar for F77, CXX ....
> 
> I guess PKG_LIBS=-fsanitize=address might work.
> 

Just a data point: that didn't work for me on OS X using clang. I had to compile R with clang + asan, because clang seems to embed the run-time only in executables, not shared objects and when linking the .so to the runtime manually it broke. But building R with clang 3.3 from trunk and gfortran from CRAN did work with some tweaking - this is what I used:
CC=/opt/clang/bin/clang CXX=/opt/clang/bin/clang++ 'CFLAGS=-fsanitize=address -O1 -fno-omit-frame-pointer -g -Wall' 'CXXFLAGS=-fsanitize=address -O1 -fno-omit-frame-pointer -g -Wall' 'LDFLAGS=-fsanitize=address -L/usr/local/lib -lgfortran' 'FC=gfortran-4.2 -m64' 'F77=gfortran-4.2 -m64'

Another data point is that R segfaulted on start for me when compiled with gcc 4.8.0-3 from Debian experimental (amd64) with asan enabled (and I gave up when I couldn't get gfortran-4.8 to mix with clang-3.2 to try that route). Those are all very fragile tools, so it's not unexpected, but essentially it seems that it's not trivial to get a working set of tools...

Cheers,
Simon



> 
> 
> '
>> 
>> Thomas Petzoldt
>> 
>> 
>> 
> 
> 
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Linux distribution with gcc 4.8 and AddressSanitizer ?
Simon Urbanek