You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Masakazu Kitajo <ma...@apache.org> on 2016/01/12 09:40:18 UTC

Build with ASAN

Hi there,

I can enable ASAN with -fsanitize=address flag but I also needed to remove
-no-undefined flag manually from some modules' Makefiles.

Without the modification, I get link errors such like below:
https://paste.apache.org/5sR6

According to the wiki, it seems we can't use ASAN with -no-undefined.
https://github.com/google/sanitizers/wiki/AddressSanitizer

So my questions are:
- How do you enable ASAN? (How/Where do you specify the flag?)
- How can I avoid the link error without manual modifications?

My build environment is OS X (Yosemite) with Apple LLVM version 7.0.2
(clang-700.1.81)

Thanks,
Masakazu

Re: Build with ASAN

Posted by Jason Kenny <jk...@yahoo-inc.com.INVALID>.
Hi,
I have not built with asan with clang on the mac. I have built for RHEL 6 and 7. I had to configure with these options.
CXXFLAGS -fno-omit-frame-pointer -fsanitize=address -static-libasan\
CFLAGS="-fno-omit-frame-pointer -fsanitize=address -static-libasan"\--disable-freelist\LUA_LDFLAGS="-fno-omit-frame-pointer -fsanitize=address -pthread -static-libasan"

This seemed to work for me. On newer systems i was having issues with Lua breaking the build as the tools has memory leaks in it. You can work around it by disabling Lua or just trying to add flags to CXXFLAGS at risk that something might not be reported correctly in the lua and or c code.
On linux at least if i was getting link errors it was because the libasan library was not installed.
The mac from my experience is different from linux so this might not translate to the mac 100%
Hope this helps Jason 
 

      From: Masakazu Kitajo <ma...@apache.org>
 To: dev@trafficserver.apache.org 
 Sent: Tuesday, January 12, 2016 2:40 AM
 Subject: Build with ASAN
   
Hi there,

I can enable ASAN with -fsanitize=address flag but I also needed to remove
-no-undefined flag manually from some modules' Makefiles.

Without the modification, I get link errors such like below:
https://paste.apache.org/5sR6

According to the wiki, it seems we can't use ASAN with -no-undefined.
https://github.com/google/sanitizers/wiki/AddressSanitizer

So my questions are:
- How do you enable ASAN? (How/Where do you specify the flag?)
- How can I avoid the link error without manual modifications?

My build environment is OS X (Yosemite) with Apple LLVM version 7.0.2
(clang-700.1.81)

Thanks,
Masakazu


  

Re: Build with ASAN

Posted by Masakazu Kitajo <ma...@apache.org>.
It seems the issue is caused by libtool.

clang refers to libclang_rt.asan_osx_dynamic.dylib automatically if
-fsanitize=address flag has been passed. However, libtool-2.4.6 drops
the flag[1][2].

The last commit of libtool adds support for the flag[3]. I modified
libtool.sh in my TS build tree, and it works (with -no-undefined
flag).

So, a workaround is, as described in the FAQ, put the flag in CC and
CXX when you run configure.
CC="clang -fsanitize=address" CXX="clang++ -fsanitize=address"
CXXFLAGS="-Werror -fsanitize=address" CFLAGS="-Werror
-fsanitize=address" LDFLAGS="-fsanitize=address" ./configure
--disable-luajit

[1] https://lists.gnu.org/archive/html/libtool/2014-04/msg00026.html
[2] http://www.gnu.org/software/libtool/manual/libtool.html#Stripped-link-flags
[3] http://git.savannah.gnu.org/cgit/libtool.git/commit/?id=a5c6466528c060cc4660ad0319c00740db0e42ba

On Wed, Jan 13, 2016 at 9:32 PM, Masakazu Kitajo <m4...@gmail.com> wrote:
> Thank you all.
>
> I tried Bryan's command line, but I'm still not able to build with
> -no-undefined flag.  -static-libasan flag doesn't work too.
>
> I'm going to dig a little deeper. It might be needed on TS-3939.
>
>
> Masakazu
>
>
> On Wed, Jan 13, 2016 at 5:57 AM, Bryan Call <bc...@apache.org> wrote:
>>
>> Free lists are runtime configurable with master and compile time with
>> 6.0.0 and earlier releases.
>>
>> -Bryan
>>
>>
>>
>>
>> > On Jan 12, 2016, at 10:58 AM, Brian Geffon <br...@gmail.com>
>> > wrote:
>> >
>> > Make sure to disable freelists too otherwise you'll miss out a number of
>> > potential issues. Also, I've always disabled lua_jit w/ ASAN.
>> >
>> > Brian
>> >
>> > On Wed, Jan 13, 2016 at 2:21 AM, Bryan Call <bc...@apache.org> wrote:
>> >
>> >> This is how I configure my bulids:
>> >>
>> >> With ASAN:
>> >> [bcall@homer ~]$ type tsconfig_asan
>> >> tsconfig_asan is aliased to `CXXFLAGS="-Werror -fno-omit-frame-pointer
>> >> -fsanitize=address" CFLAGS="-Werror" ./configure --enable-ccache
>> >> --enable-experimental-plugins --enable-example-plugins’
>> >>
>> >> Without ASAN:
>> >> [bcall@homer ~]$ type tsconfig
>> >> tsconfig is aliased to `CXXFLAGS="-Werror" CFLAGS="-Werror" ./configure
>> >> --enable-ccache --enable-experimental-plugins’
>> >>
>> >> -Bryan
>> >>
>> >>
>> >>
>> >>
>> >>> On Jan 12, 2016, at 12:40 AM, Masakazu Kitajo <ma...@apache.org>
>> >>> wrote:
>> >>>
>> >>> Hi there,
>> >>>
>> >>> I can enable ASAN with -fsanitize=address flag but I also needed to
>> >> remove
>> >>> -no-undefined flag manually from some modules' Makefiles.
>> >>>
>> >>> Without the modification, I get link errors such like below:
>> >>> https://paste.apache.org/5sR6
>> >>>
>> >>> According to the wiki, it seems we can't use ASAN with -no-undefined.
>> >>> https://github.com/google/sanitizers/wiki/AddressSanitizer
>> >>>
>> >>> So my questions are:
>> >>> - How do you enable ASAN? (How/Where do you specify the flag?)
>> >>> - How can I avoid the link error without manual modifications?
>> >>>
>> >>> My build environment is OS X (Yosemite) with Apple LLVM version 7.0.2
>> >>> (clang-700.1.81)
>> >>>
>> >>> Thanks,
>> >>> Masakazu
>> >>
>> >>
>>
>

Re: Build with ASAN

Posted by Masakazu Kitajo <m4...@gmail.com>.
Thank you all.

I tried Bryan's command line, but I'm still not able to build with
-no-undefined flag.  -static-libasan flag doesn't work too.

I'm going to dig a little deeper. It might be needed on TS-3939.


Masakazu

On Wed, Jan 13, 2016 at 5:57 AM, Bryan Call <bc...@apache.org> wrote:

> Free lists are runtime configurable with master and compile time with
> 6.0.0 and earlier releases.
>
> -Bryan
>
>
>
>
> > On Jan 12, 2016, at 10:58 AM, Brian Geffon <br...@gmail.com>
> wrote:
> >
> > Make sure to disable freelists too otherwise you'll miss out a number of
> > potential issues. Also, I've always disabled lua_jit w/ ASAN.
> >
> > Brian
> >
> > On Wed, Jan 13, 2016 at 2:21 AM, Bryan Call <bc...@apache.org> wrote:
> >
> >> This is how I configure my bulids:
> >>
> >> With ASAN:
> >> [bcall@homer ~]$ type tsconfig_asan
> >> tsconfig_asan is aliased to `CXXFLAGS="-Werror -fno-omit-frame-pointer
> >> -fsanitize=address" CFLAGS="-Werror" ./configure --enable-ccache
> >> --enable-experimental-plugins --enable-example-plugins’
> >>
> >> Without ASAN:
> >> [bcall@homer ~]$ type tsconfig
> >> tsconfig is aliased to `CXXFLAGS="-Werror" CFLAGS="-Werror" ./configure
> >> --enable-ccache --enable-experimental-plugins’
> >>
> >> -Bryan
> >>
> >>
> >>
> >>
> >>> On Jan 12, 2016, at 12:40 AM, Masakazu Kitajo <ma...@apache.org>
> wrote:
> >>>
> >>> Hi there,
> >>>
> >>> I can enable ASAN with -fsanitize=address flag but I also needed to
> >> remove
> >>> -no-undefined flag manually from some modules' Makefiles.
> >>>
> >>> Without the modification, I get link errors such like below:
> >>> https://paste.apache.org/5sR6
> >>>
> >>> According to the wiki, it seems we can't use ASAN with -no-undefined.
> >>> https://github.com/google/sanitizers/wiki/AddressSanitizer
> >>>
> >>> So my questions are:
> >>> - How do you enable ASAN? (How/Where do you specify the flag?)
> >>> - How can I avoid the link error without manual modifications?
> >>>
> >>> My build environment is OS X (Yosemite) with Apple LLVM version 7.0.2
> >>> (clang-700.1.81)
> >>>
> >>> Thanks,
> >>> Masakazu
> >>
> >>
>
>

Re: Build with ASAN

Posted by Bryan Call <bc...@apache.org>.
Free lists are runtime configurable with master and compile time with 6.0.0 and earlier releases.

-Bryan




> On Jan 12, 2016, at 10:58 AM, Brian Geffon <br...@gmail.com> wrote:
> 
> Make sure to disable freelists too otherwise you'll miss out a number of
> potential issues. Also, I've always disabled lua_jit w/ ASAN.
> 
> Brian
> 
> On Wed, Jan 13, 2016 at 2:21 AM, Bryan Call <bc...@apache.org> wrote:
> 
>> This is how I configure my bulids:
>> 
>> With ASAN:
>> [bcall@homer ~]$ type tsconfig_asan
>> tsconfig_asan is aliased to `CXXFLAGS="-Werror -fno-omit-frame-pointer
>> -fsanitize=address" CFLAGS="-Werror" ./configure --enable-ccache
>> --enable-experimental-plugins --enable-example-plugins’
>> 
>> Without ASAN:
>> [bcall@homer ~]$ type tsconfig
>> tsconfig is aliased to `CXXFLAGS="-Werror" CFLAGS="-Werror" ./configure
>> --enable-ccache --enable-experimental-plugins’
>> 
>> -Bryan
>> 
>> 
>> 
>> 
>>> On Jan 12, 2016, at 12:40 AM, Masakazu Kitajo <ma...@apache.org> wrote:
>>> 
>>> Hi there,
>>> 
>>> I can enable ASAN with -fsanitize=address flag but I also needed to
>> remove
>>> -no-undefined flag manually from some modules' Makefiles.
>>> 
>>> Without the modification, I get link errors such like below:
>>> https://paste.apache.org/5sR6
>>> 
>>> According to the wiki, it seems we can't use ASAN with -no-undefined.
>>> https://github.com/google/sanitizers/wiki/AddressSanitizer
>>> 
>>> So my questions are:
>>> - How do you enable ASAN? (How/Where do you specify the flag?)
>>> - How can I avoid the link error without manual modifications?
>>> 
>>> My build environment is OS X (Yosemite) with Apple LLVM version 7.0.2
>>> (clang-700.1.81)
>>> 
>>> Thanks,
>>> Masakazu
>> 
>> 


Re: Build with ASAN

Posted by Brian Geffon <br...@gmail.com>.
Make sure to disable freelists too otherwise you'll miss out a number of
potential issues. Also, I've always disabled lua_jit w/ ASAN.

Brian

On Wed, Jan 13, 2016 at 2:21 AM, Bryan Call <bc...@apache.org> wrote:

> This is how I configure my bulids:
>
> With ASAN:
> [bcall@homer ~]$ type tsconfig_asan
> tsconfig_asan is aliased to `CXXFLAGS="-Werror -fno-omit-frame-pointer
> -fsanitize=address" CFLAGS="-Werror" ./configure --enable-ccache
> --enable-experimental-plugins --enable-example-plugins’
>
> Without ASAN:
> [bcall@homer ~]$ type tsconfig
> tsconfig is aliased to `CXXFLAGS="-Werror" CFLAGS="-Werror" ./configure
> --enable-ccache --enable-experimental-plugins’
>
> -Bryan
>
>
>
>
> > On Jan 12, 2016, at 12:40 AM, Masakazu Kitajo <ma...@apache.org> wrote:
> >
> > Hi there,
> >
> > I can enable ASAN with -fsanitize=address flag but I also needed to
> remove
> > -no-undefined flag manually from some modules' Makefiles.
> >
> > Without the modification, I get link errors such like below:
> > https://paste.apache.org/5sR6
> >
> > According to the wiki, it seems we can't use ASAN with -no-undefined.
> > https://github.com/google/sanitizers/wiki/AddressSanitizer
> >
> > So my questions are:
> > - How do you enable ASAN? (How/Where do you specify the flag?)
> > - How can I avoid the link error without manual modifications?
> >
> > My build environment is OS X (Yosemite) with Apple LLVM version 7.0.2
> > (clang-700.1.81)
> >
> > Thanks,
> > Masakazu
>
>

Re: Build with ASAN

Posted by Bryan Call <bc...@apache.org>.
This is how I configure my bulids:

With ASAN:
[bcall@homer ~]$ type tsconfig_asan
tsconfig_asan is aliased to `CXXFLAGS="-Werror -fno-omit-frame-pointer -fsanitize=address" CFLAGS="-Werror" ./configure --enable-ccache --enable-experimental-plugins --enable-example-plugins’

Without ASAN:
[bcall@homer ~]$ type tsconfig
tsconfig is aliased to `CXXFLAGS="-Werror" CFLAGS="-Werror" ./configure --enable-ccache --enable-experimental-plugins’

-Bryan




> On Jan 12, 2016, at 12:40 AM, Masakazu Kitajo <ma...@apache.org> wrote:
> 
> Hi there,
> 
> I can enable ASAN with -fsanitize=address flag but I also needed to remove
> -no-undefined flag manually from some modules' Makefiles.
> 
> Without the modification, I get link errors such like below:
> https://paste.apache.org/5sR6
> 
> According to the wiki, it seems we can't use ASAN with -no-undefined.
> https://github.com/google/sanitizers/wiki/AddressSanitizer
> 
> So my questions are:
> - How do you enable ASAN? (How/Where do you specify the flag?)
> - How can I avoid the link error without manual modifications?
> 
> My build environment is OS X (Yosemite) with Apple LLVM version 7.0.2
> (clang-700.1.81)
> 
> Thanks,
> Masakazu