GitHub user dawiddr opened a pull request:

    https://github.com/apache/thrift/pull/1065

    Remove AC_FUNC_MALLOC and AC_FUNC_REALLOC to fix building with Address 
Sanitizer

    Compilation of Thrift fails when Clang with Address Sanitizer is used:
    
    ```
    $ ./bootstrap.sh
    $ ./configure CC=/usr/bin/clang-3.8 CXX=/usr/bin/clang++-3.8 
LD=/usr/bin/clang-3.8 CPPFLAGS=-fsanitize=address CFLAGS=-fsanitize=address 
LDFLAGS=-fsanitize=address
    $ make
    
    libtool: compile:  /usr/bin/clang++-3.8 -DHAVE_CONFIG_H -I. -I../.. 
-I../../lib/cpp/src/thrift -I../../lib/c_glib/src/thrift -I/usr/include 
-I/home/drechny/.linuxbrew/Cellar/openssl/1.0.2c/include -I./src 
-D__STDC_LIMIT_MACROS -fsanitize=address -Wall -Wextra -pedantic -g -O2 
-std=c++11 -MT src/thrift/TApplicationException.lo -MD -MP -MF 
src/thrift/.deps/TApplicationException.Tpo -c 
src/thrift/TApplicationException.cpp -o src/thrift/TApplicationException.o
    In file included from src/thrift/TApplicationException.cpp:20:
    In file included from ./src/thrift/TApplicationException.h:23:
    In file included from ./src/thrift/Thrift.h:37:
    In file included from 
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/string:52:
    In file included from 
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/bits/basic_string.h:5402:
    In file included from 
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/ext/string_conversions.h:41:
    
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/cstdlib:159:11:
 error: no member named 'realloc' in the global namespace
      using ::realloc;
            ~~^
    1 error generated.
    ```
    
    The reason of the failure is nicely described here: 
http://darmawan-salihun.blogspot.nl/2016/01/sanitizing-your-cc-code.html
    
    This pull request removes `AC_FUNC_MALLOC` and `AC_FUNC_REALLOC` from 
`configure.ac` file, what fixes the problem. This assumes that those function 
don't serve any real purpose in Thrift, which of course might not be true.
    
    Note that after applying this change there are some memory leaks generated 
during build process. In order to make it succeed `LSAN_OPTIONS=exitcode=0` 
environment variable has to be set.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dawiddr/thrift address-sanitizer-build

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/1065.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1065
    
----
commit 3496384e66431c0d566cc1fde89b739f22cd4391
Author: Dawid Drechny <[email protected]>
Date:   2016-08-15T13:42:44Z

    Remove AC_FUNC_MALLOC and AC_FUNC_REALLOC

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to