diff --git a/.bazelrc b/.bazelrc index 209f1180ff024..02243119b8c9f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -52,11 +52,15 @@ build:asan --config=sanitizer # ASAN install its signal handler, disable ours so the stacktrace will be printed by ASAN build:asan --define signal_trace=disabled build:asan --define ENVOY_CONFIG_ASAN=1 -build:asan --copt -fsanitize=address,undefined -build:asan --linkopt -fsanitize=address,undefined +build:asan --copt -fsanitize=leak +build:asan --linkopt -fsanitize=leak +build:asan --copt=-fno-omit-frame-pointer +#build:asan --copt -fsanitize=address,undefined +#build:asan --linkopt -fsanitize=address,undefined # vptr and function sanitizer are enabled in clang-asan if it is set up via bazel/setup_clang.sh. build:asan --copt -fno-sanitize=vptr,function build:asan --linkopt -fno-sanitize=vptr,function +build:asan --linkopt -fno-omit-frame-pointer build:asan --copt -DADDRESS_SANITIZER=1 build:asan --copt -D__SANITIZE_ADDRESS__ build:asan --test_env=ASAN_OPTIONS=handle_abort=1:allow_addr2line=true:check_initialization_order=true:strict_init_order=true:detect_odr_violation=1 @@ -116,6 +120,7 @@ build:libc++ --action_env=BAZEL_CXXOPTS=-stdlib=libc++ build:libc++ --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a build:libc++ --action_env=BAZEL_LINKOPTS=-lm:-pthread build:libc++ --define force_libcpp=enabled +#lambdai build:libc++ --copt -fsanitize=leak # Optimize build for binary size reduction. build:sizeopt -c opt --copt -Os diff --git a/source/exe/main.cc b/source/exe/main.cc index 80cfc86f18b0f..8ae2f9c872a7b 100644 --- a/source/exe/main.cc +++ b/source/exe/main.cc @@ -1,5 +1,6 @@ +#include "common/common/macros.h" #include "exe/main_common.h" - +#include // NOLINT(namespace-envoy) /** @@ -9,4 +10,14 @@ * deployment such as initializing signal handling. It calls main_common * after setting up command line options. */ -int main(int argc, char** argv) { return Envoy::MainCommon::main(argc, argv); } +int main(int argc, char** argv) { + auto pnew = new (int)(7); + pnew = nullptr; // The memory is leaked here. + auto pmalloc = malloc(7); + pmalloc = nullptr; // The memory is leaked here. + std::cout << "foo: after malloc and new" << std::endl; + return Envoy::MainCommon::main(argc, argv); + // UNREFERENCED_PARAMETER(argc); + // UNREFERENCED_PARAMETER(argv); + // return 0; +}