diff --git a/.bazelrc b/.bazelrc index a77ca3f3d92a5..84c7ecf7fa6ee 100644 --- a/.bazelrc +++ b/.bazelrc @@ -115,7 +115,8 @@ coverage --config=coverage build:coverage --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1 build:coverage --action_env=GCOV=llvm-profdata build:coverage --copt=-DNDEBUG -build:coverage --test_timeout=900 +# Doubling timeout in all categories +build:coverage --test_timeout=120,600,1800,7200 build:coverage --define=ENVOY_CONFIG_COVERAGE=1 build:coverage --cxxopt="-DENVOY_CONFIG_COVERAGE=1" build:coverage --coverage_support=@envoy//bazel/coverage:coverage_support @@ -182,7 +183,7 @@ build:remote-msan --config=rbe-toolchain-msan # Docker sandbox # NOTE: Update this from https://github.com/envoyproxy/envoy-build-tools/blob/master/toolchains/rbe_toolchains_config.bzl#L8 -build:docker-sandbox --experimental_docker_image=envoyproxy/envoy-build-ubuntu:04f06115b6ee7cfea74930353fb47a41149cbec3 +build:docker-sandbox --experimental_docker_image=envoyproxy/envoy-build-ubuntu:12b3d2c2ffa582507e5d6dd34632b2b990f1b195 build:docker-sandbox --spawn_strategy=docker build:docker-sandbox --strategy=Javac=docker build:docker-sandbox --strategy=Closure=docker diff --git a/.circleci/config.yml b/.circleci/config.yml index ab33aac578810..5efd1289cb1f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ executors: description: "A regular build executor based on ubuntu image" docker: # NOTE: Update this from https://github.com/envoyproxy/envoy-build-tools/blob/master/toolchains/rbe_toolchains_config.bzl#L8 - - image: envoyproxy/envoy-build-ubuntu:04f06115b6ee7cfea74930353fb47a41149cbec3 + - image: envoyproxy/envoy-build-ubuntu:12b3d2c2ffa582507e5d6dd34632b2b990f1b195 resource_class: xlarge working_directory: /source diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 35439f303f242..ad93066b0d0a7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM gcr.io/envoy-ci/envoy-build:04f06115b6ee7cfea74930353fb47a41149cbec3 +FROM gcr.io/envoy-ci/envoy-build:12b3d2c2ffa582507e5d6dd34632b2b990f1b195 ARG USERNAME=vscode ARG USER_UID=501 diff --git a/bazel/README.md b/bazel/README.md index 435c5b29d2121..ee6ce43eb1b5d 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -267,7 +267,7 @@ for more details. ## Supported compiler versions We now require Clang >= 5.0 due to known issues with std::string thread safety and C++14 support. GCC >= 7 is also -known to work. Currently the CI is running with Clang 9. +known to work. Currently the CI is running with Clang 10. ## Clang STL debug symbols @@ -725,7 +725,7 @@ also have 'buildifier' installed from the bazel distribution. Edit the paths shown here to reflect the installation locations on your system: ```shell -export CLANG_FORMAT="$HOME/ext/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-format" +export CLANG_FORMAT="$HOME/ext/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-format" export BUILDIFIER_BIN="/usr/bin/buildifier" ``` diff --git a/bazel/external/compiler_rt.BUILD b/bazel/external/compiler_rt.BUILD index 82dfe8f8be030..dbcb1be5134d7 100644 --- a/bazel/external/compiler_rt.BUILD +++ b/bazel/external/compiler_rt.BUILD @@ -4,6 +4,6 @@ licenses(["notice"]) # Apache 2 cc_library( name = "fuzzed_data_provider", - hdrs = ["fuzzer/utils/FuzzedDataProvider.h"], + hdrs = ["fuzzer/FuzzedDataProvider.h"], visibility = ["//visibility:public"], ) diff --git a/bazel/foreign_cc/nghttp2.patch b/bazel/foreign_cc/nghttp2.patch index 55768dca20036..91ddf1898e45b 100644 --- a/bazel/foreign_cc/nghttp2.patch +++ b/bazel/foreign_cc/nghttp2.patch @@ -15,3 +15,73 @@ index 35c77d1d..47bd63f5 100644 endif() # AC_TYPE_UINT8_T # AC_TYPE_UINT16_T +# https://github.com/nghttp2/nghttp2/pull/1468 +diff --git a/lib/nghttp2_buf.c b/lib/nghttp2_buf.c +index 2a435bebf..92f97f7f2 100644 +--- a/lib/nghttp2_buf.c ++++ b/lib/nghttp2_buf.c +@@ -82,8 +82,10 @@ void nghttp2_buf_reset(nghttp2_buf *buf) { + } + + void nghttp2_buf_wrap_init(nghttp2_buf *buf, uint8_t *begin, size_t len) { +- buf->begin = buf->pos = buf->last = buf->mark = begin; +- buf->end = begin + len; ++ buf->begin = buf->pos = buf->last = buf->mark = buf->end = begin; ++ if (buf->end != NULL) { ++ buf->end += len; ++ } + } + + static int buf_chain_new(nghttp2_buf_chain **chain, size_t chunk_length, +diff --git a/lib/nghttp2_frame.c b/lib/nghttp2_frame.c +index 4821de408..940c723b0 100644 +--- a/lib/nghttp2_frame.c ++++ b/lib/nghttp2_frame.c +@@ -818,8 +818,10 @@ int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame, + size_t len = 0; + + origin = frame->payload; +- p = payload; +- end = p + payloadlen; ++ p = end = payload; ++ if (end != NULL) { ++ end += payloadlen; ++ } + + for (; p != end;) { + if (end - p < 2) { +diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c +index 563ccd7de..794f141a1 100644 +--- a/lib/nghttp2_session.c ++++ b/lib/nghttp2_session.c +@@ -5349,7 +5349,7 @@ static ssize_t inbound_frame_effective_readlen(nghttp2_inbound_frame *iframe, + + ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + size_t inlen) { +- const uint8_t *first = in, *last = in + inlen; ++ const uint8_t *first = in, *last = in; + nghttp2_inbound_frame *iframe = &session->iframe; + size_t readlen; + ssize_t padlen; +@@ -5360,6 +5360,10 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + size_t pri_fieldlen; + nghttp2_mem *mem; + ++ if (in != NULL) { ++ last += inlen; ++ } ++ + DEBUGF("recv: connection recv_window_size=%d, local_window=%d\n", + session->recv_window_size, session->local_window_size); + +@@ -5389,7 +5393,9 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + } + + iframe->payloadleft -= readlen; +- in += readlen; ++ if (in != NULL) { ++ in += readlen; ++ } + + if (iframe->payloadleft == 0) { + session_inbound_frame_reset(session); diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 417b9507f670e..e8b193983ac12 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -67,10 +67,10 @@ DEPENDENCY_REPOSITORIES = dict( use_category = ["build"], ), envoy_build_tools = dict( - sha256 = "78e794ae1c1197f59b7ecbf8bd62c053ecb1625daaccdbe287581ee6f12ec0fb", - strip_prefix = "envoy-build-tools-b47394aa94c45e15c479d18eab18ffd43ec62d89", - # 2020-05-14 - urls = ["https://github.com/envoyproxy/envoy-build-tools/archive/b47394aa94c45e15c479d18eab18ffd43ec62d89.tar.gz"], + sha256 = "b0efe70a1d122fffb89570771f4ec3b912aa0a8a0ce56218223918d7737d01e2", + strip_prefix = "envoy-build-tools-3cbc1d66b9e9ead42daf69e01597cacf4fb52151", + # 2020-05-15 + urls = ["https://github.com/envoyproxy/envoy-build-tools/archive/3cbc1d66b9e9ead42daf69e01597cacf4fb52151.tar.gz"], use_category = ["build"], ), boringssl = dict( @@ -443,10 +443,10 @@ DEPENDENCY_REPOSITORIES = dict( # provided as part of the compiler-rt source distribution. We can't use the # Clang variant as we are not a Clang-LLVM only shop today. org_llvm_releases_compiler_rt = dict( - sha256 = "56e4cd96dd1d8c346b07b4d6b255f976570c6f2389697347a6c3dcb9e820d10e", + sha256 = "6a7da64d3a0a7320577b68b9ca4933bdcab676e898b759850e827333c3282c75", # Only allow peeking at fuzzer related files for now. - strip_prefix = "compiler-rt-9.0.0.src/lib", - urls = ["http://releases.llvm.org/9.0.0/compiler-rt-9.0.0.src.tar.xz"], + strip_prefix = "compiler-rt-10.0.0.src/include", + urls = ["https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/compiler-rt-10.0.0.src.tar.xz"], use_category = ["test"], ), upb = dict( diff --git a/ci/README.md b/ci/README.md index e7d52fba450a5..a137ea7e61296 100644 --- a/ci/README.md +++ b/ci/README.md @@ -32,8 +32,8 @@ running tests that reflects the latest built Windows 2019 Envoy image. Currently there are three build images for Linux and one for Windows: * `envoyproxy/envoy-build` — alias to `envoyproxy/envoy-build-ubuntu`. -* `envoyproxy/envoy-build-ubuntu` — based on Ubuntu 18.04 (Bionic) with GCC 9 and Clang 9 compiler. -* `envoyproxy/envoy-build-centos` — based on CentOS 7 with GCC 9 and Clang 9 compiler, this image is experimental and not well tested. +* `envoyproxy/envoy-build-ubuntu` — based on Ubuntu 18.04 (Bionic) with GCC 9 and Clang 10 compiler. +* `envoyproxy/envoy-build-centos` — based on CentOS 7 with GCC 9 and Clang 10 compiler, this image is experimental and not well tested. * `envoyproxy/envoy-build-windows2019` — based on Windows 2019 LTS with VS 2019 Build Tools. The source for these images is located in the [envoyproxy/envoy-build-tools](https://github.com/envoyproxy/envoy-build-tools) diff --git a/ci/run_envoy_docker.sh b/ci/run_envoy_docker.sh index b1059c893b8a7..886a2347d3787 100755 --- a/ci/run_envoy_docker.sh +++ b/ci/run_envoy_docker.sh @@ -17,7 +17,7 @@ USER_GROUP=root [[ -z "${ENVOY_DOCKER_BUILD_DIR}" ]] && ENVOY_DOCKER_BUILD_DIR=/tmp/envoy-docker-build [[ -t 1 ]] && ENVOY_DOCKER_OPTIONS+=" -it" -[[ -f .git ]] && [[ ! -d .git ]] && ENVOY_DOCKER_OPTIONS+=" -v \"$(git rev-parse --git-common-dir):$(git rev-parse --git-common-dir)\"" +[[ -f .git ]] && [[ ! -d .git ]] && ENVOY_DOCKER_OPTIONS+=" -v $(git rev-parse --git-common-dir):$(git rev-parse --git-common-dir)" export ENVOY_BUILD_IMAGE="${IMAGE_NAME}:${IMAGE_ID}" diff --git a/docs/root/version_history/current.rst b/docs/root/version_history/current.rst index 8cb2ef04c5080..2740b74a15116 100644 --- a/docs/root/version_history/current.rst +++ b/docs/root/version_history/current.rst @@ -53,6 +53,8 @@ New Features * access loggers: extened specifier for FilterStateFormatter to output :ref:`unstructured log string `. * access loggers: file access logger config added :ref:`log_format `. * aggregate cluster: make route :ref:`retry_priority ` predicates work with :ref:`this cluster type `. +* build: official released binary is now built on Ubuntu 18.04, requires glibc >= 2.27. +* build: official released binary is now built with Clang 10.0.0. * compressor: generic :ref:`compressor ` filter exposed to users. * config: added :ref:`identifier ` stat that reflects control plane identifier. * config: added :ref:`version_text ` stat that reflects xDS version. diff --git a/source/common/common/thread.h b/source/common/common/thread.h index bbad9fee6913c..4808d391dfbdc 100644 --- a/source/common/common/thread.h +++ b/source/common/common/thread.h @@ -64,9 +64,9 @@ class CondVar { * @return WaitStatus whether the condition timed out or not. */ template - WaitStatus waitFor( - MutexBasicLockable& mutex, - std::chrono::duration duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) { + WaitStatus waitFor(MutexBasicLockable& mutex, + std::chrono::duration duration) noexcept + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) { return condvar_.WaitWithTimeout(&mutex.mutex_, absl::FromChrono(duration)) ? WaitStatus::Timeout : WaitStatus::NoTimeout; diff --git a/source/common/stats/symbol_table_impl.h b/source/common/stats/symbol_table_impl.h index e620637b2a152..baf8622672274 100644 --- a/source/common/stats/symbol_table_impl.h +++ b/source/common/stats/symbol_table_impl.h @@ -386,12 +386,7 @@ class StatName { return H::combine(std::move(h), absl::string_view()); } - // Casts the raw data as a string_view. Note that this string_view will not - // be in human-readable form, but it will be compatible with a string-view - // hasher. - const char* cdata = reinterpret_cast(stat_name.data()); - absl::string_view data_as_string_view = absl::string_view(cdata, stat_name.dataSize()); - return H::combine(std::move(h), data_as_string_view); + return H::combine(std::move(h), stat_name.dataAsStringView()); } /** @@ -403,8 +398,7 @@ class StatName { uint64_t hash() const { return absl::Hash()(*this); } bool operator==(const StatName& rhs) const { - const uint64_t sz = dataSize(); - return sz == rhs.dataSize() && memcmp(data(), rhs.data(), sz * sizeof(uint8_t)) == 0; + return dataAsStringView() == rhs.dataAsStringView(); } bool operator!=(const StatName& rhs) const { return !(*this == rhs); } @@ -452,6 +446,9 @@ class StatName { * @return A pointer to the first byte of data (skipping over size bytes). */ const uint8_t* data() const { + if (size_and_data_ == nullptr) { + return nullptr; + } return size_and_data_ + SymbolTableImpl::Encoding::encodingSizeBytes(dataSize()); } @@ -463,6 +460,15 @@ class StatName { bool empty() const { return size_and_data_ == nullptr || dataSize() == 0; } private: + /** + * Casts the raw data as a string_view. Note that this string_view will not + * be in human-readable form, but it will be compatible with a string-view + * hasher and comparator. + */ + absl::string_view dataAsStringView() const { + return {reinterpret_cast(data()), dataSize()}; + } + const uint8_t* size_and_data_{nullptr}; }; diff --git a/source/extensions/common/tap/admin.cc b/source/extensions/common/tap/admin.cc index b6c4449db1774..9dc6b9b08411e 100644 --- a/source/extensions/common/tap/admin.cc +++ b/source/extensions/common/tap/admin.cc @@ -110,7 +110,7 @@ void AdminHandler::AdminPerTapSinkHandle::submitTrace( std::shared_ptr shared_trace{std::move(trace)}; // The handle can be destroyed before the cross thread post is complete. Thus, we capture a // reference to our parent. - parent_.main_thread_dispatcher_.post([& parent = parent_, trace = shared_trace, format]() { + parent_.main_thread_dispatcher_.post([&parent = parent_, trace = shared_trace, format]() { if (!parent.attached_request_.has_value()) { return; } diff --git a/source/extensions/common/tap/tap_config_base.h b/source/extensions/common/tap/tap_config_base.h index 519f875620634..59b53da027f65 100644 --- a/source/extensions/common/tap/tap_config_base.h +++ b/source/extensions/common/tap/tap_config_base.h @@ -53,7 +53,9 @@ class Utility { const uint32_t start_offset_trim = std::min(start_offset, slice.len_); slice.len_ -= start_offset_trim; start_offset -= start_offset_trim; - slice.mem_ = static_cast(slice.mem_) + start_offset_trim; + if (slice.mem_ != nullptr) { + slice.mem_ = static_cast(slice.mem_) + start_offset_trim; + } const uint32_t final_length = std::min(length, slice.len_); slice.len_ = final_length; diff --git a/source/extensions/filters/http/ext_authz/ext_authz.cc b/source/extensions/filters/http/ext_authz/ext_authz.cc index a5960424dc28f..38d62a85a051c 100644 --- a/source/extensions/filters/http/ext_authz/ext_authz.cc +++ b/source/extensions/filters/http/ext_authz/ext_authz.cc @@ -212,7 +212,7 @@ void Filter::onComplete(Filters::Common::ExtAuthz::ResponsePtr&& response) { callbacks_->sendLocalReply( response->status_code, response->body, - [& headers = response->headers_to_add, + [&headers = response->headers_to_add, &callbacks = *callbacks_](Http::HeaderMap& response_headers) -> void { ENVOY_STREAM_LOG(trace, "ext_authz filter added header(s) to the local response:", callbacks); diff --git a/test/common/http/utility_test.cc b/test/common/http/utility_test.cc index 70213c6feb67f..d4320cd19324e 100644 --- a/test/common/http/utility_test.cc +++ b/test/common/http/utility_test.cc @@ -665,10 +665,9 @@ TEST(HttpUtility, ResolveMostSpecificPerFilterConfigGeneric) { const std::string filter_name = "envoy.filter"; NiceMock filter_callbacks; - const Router::RouteSpecificFilterConfig* nullconfig = nullptr; - const Router::RouteSpecificFilterConfig* one = nullconfig + 1; - const Router::RouteSpecificFilterConfig* two = nullconfig + 2; - const Router::RouteSpecificFilterConfig* three = nullconfig + 3; + const Router::RouteSpecificFilterConfig one; + const Router::RouteSpecificFilterConfig two; + const Router::RouteSpecificFilterConfig three; // Test when there's nothing on the route EXPECT_EQ(nullptr, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, @@ -676,23 +675,23 @@ TEST(HttpUtility, ResolveMostSpecificPerFilterConfigGeneric) { // Testing in reverse order, so that the method always returns the last object. ON_CALL(filter_callbacks.route_->route_entry_.virtual_host_, perFilterConfig(filter_name)) - .WillByDefault(Return(one)); - EXPECT_EQ(one, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, - filter_callbacks.route())); + .WillByDefault(Return(&one)); + EXPECT_EQ(&one, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, + filter_callbacks.route())); - ON_CALL(*filter_callbacks.route_, perFilterConfig(filter_name)).WillByDefault(Return(two)); - EXPECT_EQ(two, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, - filter_callbacks.route())); + ON_CALL(*filter_callbacks.route_, perFilterConfig(filter_name)).WillByDefault(Return(&two)); + EXPECT_EQ(&two, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, + filter_callbacks.route())); ON_CALL(filter_callbacks.route_->route_entry_, perFilterConfig(filter_name)) - .WillByDefault(Return(three)); - EXPECT_EQ(three, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, - filter_callbacks.route())); + .WillByDefault(Return(&three)); + EXPECT_EQ(&three, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, + filter_callbacks.route())); // Cover the case of no route entry ON_CALL(*filter_callbacks.route_, routeEntry()).WillByDefault(Return(nullptr)); - EXPECT_EQ(two, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, - filter_callbacks.route())); + EXPECT_EQ(&two, Utility::resolveMostSpecificPerFilterConfigGeneric(filter_name, + filter_callbacks.route())); } // Verify that traversePerFilterConfigGeneric traverses in the order of specificity. @@ -702,16 +701,16 @@ TEST(HttpUtility, TraversePerFilterConfigIteratesInOrder) { // Create configs to test; to ease of testing instead of using real objects // we will use pointers that are actually indexes. - const Router::RouteSpecificFilterConfig* nullconfig = nullptr; + const std::vector nullconfigs(5); size_t num_configs = 1; ON_CALL(filter_callbacks.route_->route_entry_.virtual_host_, perFilterConfig(filter_name)) - .WillByDefault(Return(nullconfig + num_configs)); + .WillByDefault(Return(&nullconfigs[num_configs])); num_configs++; ON_CALL(*filter_callbacks.route_, perFilterConfig(filter_name)) - .WillByDefault(Return(nullconfig + num_configs)); + .WillByDefault(Return(&nullconfigs[num_configs])); num_configs++; ON_CALL(filter_callbacks.route_->route_entry_, perFilterConfig(filter_name)) - .WillByDefault(Return(nullconfig + num_configs)); + .WillByDefault(Return(&nullconfigs[num_configs])); // a vector to save which configs are visited by the traversePerFilterConfigGeneric std::vector visited_configs(num_configs, 0); @@ -720,7 +719,7 @@ TEST(HttpUtility, TraversePerFilterConfigIteratesInOrder) { size_t index = 0; Utility::traversePerFilterConfigGeneric(filter_name, filter_callbacks.route(), [&](const Router::RouteSpecificFilterConfig& cfg) { - int cfg_index = &cfg - nullconfig; + int cfg_index = &cfg - nullconfigs.data(); visited_configs[index] = cfg_index - 1; index++; }); diff --git a/test/extensions/common/tap/tap_config_base_test.cc b/test/extensions/common/tap/tap_config_base_test.cc index 74cf5074b3f5a..75ccec5a1595f 100644 --- a/test/extensions/common/tap/tap_config_base_test.cc +++ b/test/extensions/common/tap/tap_config_base_test.cc @@ -91,6 +91,8 @@ TEST(AddBufferToProtoBytes, All) { } TEST(TrimSlice, All) { + std::string slice_mem = "static base slice memory that is long enough"; + void* test_base = static_cast(&slice_mem[0]); { std::vector slices; Utility::trimSlices(slices, 0, 100); @@ -98,63 +100,63 @@ TEST(TrimSlice, All) { } { - std::vector slices = {{nullptr, 5}}; + std::vector slices = {{test_base, 5}}; Utility::trimSlices(slices, 0, 100); - const std::vector expected{{nullptr, 5}}; + const std::vector expected{{test_base, 5}}; EXPECT_EQ(expected, slices); } { - std::vector slices = {{nullptr, 5}}; + std::vector slices = {{test_base, 5}}; Utility::trimSlices(slices, 3, 3); - const std::vector expected{{reinterpret_cast(0x3), 2}}; + const std::vector expected{{static_cast(&slice_mem[3]), 2}}; EXPECT_EQ(expected, slices); } { - std::vector slices = {{nullptr, 5}, {nullptr, 4}}; + std::vector slices = {{test_base, 5}, {test_base, 4}}; Utility::trimSlices(slices, 3, 3); - const std::vector expected{{reinterpret_cast(0x3), 2}, - {reinterpret_cast(0x0), 1}}; + const std::vector expected{{static_cast(&slice_mem[3]), 2}, + {static_cast(&slice_mem[0]), 1}}; EXPECT_EQ(expected, slices); } { - std::vector slices = {{nullptr, 5}, {nullptr, 4}}; + std::vector slices = {{test_base, 5}, {test_base, 4}}; Utility::trimSlices(slices, 6, 3); - const std::vector expected{{reinterpret_cast(0x5), 0}, - {reinterpret_cast(0x1), 3}}; + const std::vector expected{{static_cast(&slice_mem[5]), 0}, + {static_cast(&slice_mem[1]), 3}}; EXPECT_EQ(expected, slices); } { - std::vector slices = {{nullptr, 5}, {nullptr, 4}}; + std::vector slices = {{test_base, 5}, {test_base, 4}}; Utility::trimSlices(slices, 0, 0); - const std::vector expected{{reinterpret_cast(0x0), 0}, - {reinterpret_cast(0x0), 0}}; + const std::vector expected{{static_cast(&slice_mem[0]), 0}, + {static_cast(&slice_mem[0]), 0}}; EXPECT_EQ(expected, slices); } { - std::vector slices = {{nullptr, 5}, {nullptr, 4}}; + std::vector slices = {{test_base, 5}, {test_base, 4}}; Utility::trimSlices(slices, 0, 3); - const std::vector expected{{reinterpret_cast(0x0), 3}, - {reinterpret_cast(0x0), 0}}; + const std::vector expected{{static_cast(&slice_mem[0]), 3}, + {static_cast(&slice_mem[0]), 0}}; EXPECT_EQ(expected, slices); } { - std::vector slices = {{nullptr, 5}, {nullptr, 4}}; + std::vector slices = {{test_base, 5}, {test_base, 4}}; Utility::trimSlices(slices, 1, 3); - const std::vector expected{{reinterpret_cast(0x1), 3}, - {reinterpret_cast(0x0), 0}}; + const std::vector expected{{static_cast(&slice_mem[1]), 3}, + {static_cast(&slice_mem[0]), 0}}; EXPECT_EQ(expected, slices); } } diff --git a/test/extensions/filters/network/redis_proxy/command_splitter_impl_test.cc b/test/extensions/filters/network/redis_proxy/command_splitter_impl_test.cc index b8020b2a29c1b..097cb3d49f4c2 100644 --- a/test/extensions/filters/network/redis_proxy/command_splitter_impl_test.cc +++ b/test/extensions/filters/network/redis_proxy/command_splitter_impl_test.cc @@ -485,6 +485,7 @@ class FragmentedRequestCommandHandlerTest : public RedisCommandSplitterImplTest EXPECT_CALL(callbacks_, connectionAllowed()).WillOnce(Return(true)); + std::vector dummy_requests(num_gets); for (uint32_t i = 0; i < num_gets; i++) { Common::Redis::Client::PoolRequest* request_to_use = nullptr; if (std::find(null_handle_indexes.begin(), null_handle_indexes.end(), i) == @@ -494,7 +495,7 @@ class FragmentedRequestCommandHandlerTest : public RedisCommandSplitterImplTest Common::Redis::Client::PoolRequest* mirror_request_to_use = nullptr; if (std::find(null_handle_indexes.begin(), null_handle_indexes.end(), i) == null_handle_indexes.end()) { - mirror_request_to_use = &mirror_request_to_use[i]; + mirror_request_to_use = &dummy_requests[i]; } EXPECT_CALL(*conn_pool_, makeRequest_(std::to_string(i), CompositeArrayEq(expected_requests_[i]), _)) diff --git a/test/fuzz/fuzz_runner.h b/test/fuzz/fuzz_runner.h index 31a317a220c0c..5349d1241cd58 100644 --- a/test/fuzz/fuzz_runner.h +++ b/test/fuzz/fuzz_runner.h @@ -8,7 +8,7 @@ #include "libprotobuf_mutator/src/libfuzzer/libfuzzer_macro.h" // Bring in FuzzedDataProvider, see // https://github.com/google/fuzzing/blob/master/docs/split-inputs.md#fuzzed-data-provider -#include "fuzzer/utils/FuzzedDataProvider.h" +#include "fuzzer/FuzzedDataProvider.h" #include "spdlog/spdlog.h" namespace Envoy { diff --git a/test/mocks/common.h b/test/mocks/common.h index 1c5d899d975e2..57bdc20623f62 100644 --- a/test/mocks/common.h +++ b/test/mocks/common.h @@ -58,9 +58,9 @@ class MockTimeSystem : public Event::TestTimeSystem { void advanceTimeAsync(const Duration& duration) override { real_time_.advanceTimeAsync(duration); } - Thread::CondVar::WaitStatus - waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, - const Duration& duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) override { + Thread::CondVar::WaitStatus waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, + const Duration& duration) noexcept + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) override { return real_time_.waitFor(mutex, condvar, duration); // NO_CHECK_FORMAT(real_time) } MOCK_METHOD(SystemTime, systemTime, ()); diff --git a/test/per_file_coverage.sh b/test/per_file_coverage.sh index 6f5368f024bbe..cb7f14b81b512 100755 --- a/test/per_file_coverage.sh +++ b/test/per_file_coverage.sh @@ -3,52 +3,60 @@ # directory:coverage_percent # for existing extensions with low coverage. declare -a KNOWN_LOW_COVERAGE=( -"source/extensions/common:95.1" +"source/extensions/common:94.0" "source/extensions/common/crypto:91.5" -"source/extensions/common/wasm:87.8" -"source/extensions/common/wasm/v8:88.3" +"source/extensions/common/tap:95.9" +"source/extensions/common/wasm:85.4" "source/extensions/common/wasm/null:77.8" -"source/extensions/filters/network/sni_cluster:90.3" -"source/extensions/filters/network/thrift_proxy/router:96.4" -"source/extensions/filters/network/sni_dynamic_forward_proxy:92.4" -"source/extensions/filters/network/dubbo_proxy:96.7" -"source/extensions/filters/network/dubbo_proxy/router:96.1" -"source/extensions/filters/network/direct_response:89.3" -"source/extensions/filters/http/dynamic_forward_proxy:93.2" -"source/extensions/filters/http/cache:80.8" +"source/extensions/common/wasm/v8:85.4" +"source/extensions/filters/common:94.6" +"source/extensions/filters/common/expr:92.2" +"source/extensions/filters/common/fault:95.8" +"source/extensions/filters/common/lua:95.9" +"source/extensions/filters/common/rbac:87.2" +"source/extensions/filters/http/aws_lambda:96.4" +"source/extensions/filters/http/aws_request_signing:93.3" +"source/extensions/filters/http/cache:80.7" "source/extensions/filters/http/cache/simple_http_cache:84.5" -"source/extensions/filters/http/csrf:96.6" -"source/extensions/filters/http/ip_tagging:92.0" -"source/extensions/filters/http/header_to_metadata:95.0" +"source/extensions/filters/http/dynamic_forward_proxy:91.5" +"source/extensions/filters/http/ext_authz:96.5" "source/extensions/filters/http/grpc_json_transcoder:93.3" -"source/extensions/filters/http/aws_request_signing:93.3" -"source/extensions/filters/listener:95.7" -"source/extensions/filters/listener/tls_inspector:92.9" +"source/extensions/filters/http/header_to_metadata:95.0" +"source/extensions/filters/http/ip_tagging:91.2" +"source/extensions/filters/listener:95.6" "source/extensions/filters/listener/http_inspector:93.3" -"source/extensions/filters/udp:91.2" -"source/extensions/filters/udp/dns_filter:84.1" -"source/extensions/filters/common:96.4" -"source/extensions/filters/common/expr:92.2" -"source/extensions/filters/common/rbac:93.0" -"source/extensions/grpc_credentials:93.9" -"source/extensions/grpc_credentials/aws_iam:88.6" -"source/extensions/quic_listeners:85.1" -"source/extensions/quic_listeners/quiche:85.1" -"source/extensions/quic_listeners/quiche/platform:0" +"source/extensions/filters/listener/tls_inspector:92.4" +"source/extensions/filters/network/common:96.0" +"source/extensions/filters/network/common/redis:96.2" +"source/extensions/filters/network/direct_response:89.3" +"source/extensions/filters/network/dubbo_proxy:96.1" +"source/extensions/filters/network/dubbo_proxy/router:95.1" +"source/extensions/filters/network/http_connection_manager:95.9" +"source/extensions/filters/network/mongo_proxy:94.0" +"source/extensions/filters/network/sni_cluster:90.3" +"source/extensions/filters/network/sni_dynamic_forward_proxy:89.4" +"source/extensions/filters/network/thrift_proxy/router:96.0" +"source/extensions/filters/udp:91.0" +"source/extensions/filters/udp/dns_filter:88.5" +"source/extensions/grpc_credentials:92.0" +"source/extensions/grpc_credentials/aws_iam:86.8" +"source/extensions/health_checkers:95.9" +"source/extensions/health_checkers/redis:95.9" +"source/extensions/quic_listeners:84.8" +"source/extensions/quic_listeners/quiche:84.8" "source/extensions/resource_monitors/fixed_heap:90.9" "source/extensions/retry:95.5" "source/extensions/retry/host:85.7" -"source/extensions/retry/host/omit_host_metadata:96.9" -"source/extensions/retry/host/previous_hosts:82.4" "source/extensions/retry/host/omit_canary_hosts:64.3" -"source/extensions/stat_sinks/statsd:92.6" -"source/extensions/tracers:96.8" -"source/extensions/tracers/opencensus:93.9" -"source/extensions/tracers/xray:95.5" -"source/extensions/transport_sockets:95.0" +"source/extensions/retry/host/previous_hosts:82.4" +"source/extensions/stat_sinks/statsd:85.2" +"source/extensions/tracers:96.3" +"source/extensions/tracers/opencensus:90.1" +"source/extensions/tracers/xray:95.3" +"source/extensions/transport_sockets:94.8" "source/extensions/transport_sockets/raw_buffer:90.9" "source/extensions/transport_sockets/tap:95.6" -"source/extensions/transport_sockets/tls:94.5" +"source/extensions/transport_sockets/tls:94.2" "source/extensions/transport_sockets/tls/private_key:76.9" ) @@ -57,7 +65,7 @@ COVERAGE_DIR="${SRCDIR}"/generated/coverage COVERAGE_DATA="${COVERAGE_DIR}/coverage.dat" FAILED=0 -DEFAULT_COVERAGE_THRESHOLD=97.0 +DEFAULT_COVERAGE_THRESHOLD=96.6 DIRECTORY_THRESHOLD=$DEFAULT_COVERAGE_THRESHOLD # Unfortunately we have a bunch of preexisting extensions with low coverage. diff --git a/test/run_envoy_bazel_coverage.sh b/test/run_envoy_bazel_coverage.sh index 68d5ac1567c3c..84c66b79f3492 100755 --- a/test/run_envoy_bazel_coverage.sh +++ b/test/run_envoy_bazel_coverage.sh @@ -49,7 +49,7 @@ if [[ "$VALIDATE_COVERAGE" == "true" ]]; then if [[ "${FUZZ_COVERAGE}" == "true" ]]; then COVERAGE_THRESHOLD=27.0 else - COVERAGE_THRESHOLD=97.0 + COVERAGE_THRESHOLD=96.5 fi COVERAGE_FAILED=$(echo "${COVERAGE_VALUE}<${COVERAGE_THRESHOLD}" | bc) if test ${COVERAGE_FAILED} -eq 1; then diff --git a/test/test_common/simulated_time_system.cc b/test/test_common/simulated_time_system.cc index dcc0374423fd6..6577dccf003ec 100644 --- a/test/test_common/simulated_time_system.cc +++ b/test/test_common/simulated_time_system.cc @@ -248,9 +248,10 @@ void SimulatedTimeSystemHelper::waitForNoPendingLockHeld() const &pending_alarms_)); } -Thread::CondVar::WaitStatus SimulatedTimeSystemHelper::waitFor( - Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, - const Duration& duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) { +Thread::CondVar::WaitStatus SimulatedTimeSystemHelper::waitFor(Thread::MutexBasicLockable& mutex, + Thread::CondVar& condvar, + const Duration& duration) noexcept + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) { only_one_thread_.checkOneThread(); // TODO(#10568): This real-time polling delay should not be necessary. Without diff --git a/test/test_common/simulated_time_system.h b/test/test_common/simulated_time_system.h index e578bd7670718..cc34fcf953a96 100644 --- a/test/test_common/simulated_time_system.h +++ b/test/test_common/simulated_time_system.h @@ -28,9 +28,9 @@ class SimulatedTimeSystemHelper : public TestTimeSystem { // TestTimeSystem void advanceTimeWait(const Duration& duration) override; void advanceTimeAsync(const Duration& duration) override; - Thread::CondVar::WaitStatus - waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, - const Duration& duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) override; + Thread::CondVar::WaitStatus waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, + const Duration& duration) noexcept + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) override; // TimeSource SystemTime systemTime() override; diff --git a/test/test_common/test_time.h b/test/test_common/test_time.h index 4b0beec54439f..f5e24b8bd8a56 100644 --- a/test/test_common/test_time.h +++ b/test/test_common/test_time.h @@ -14,9 +14,9 @@ class TestRealTimeSystem : public TestTimeSystem { // TestTimeSystem void advanceTimeAsync(const Duration& duration) override; void advanceTimeWait(const Duration& duration) override; - Thread::CondVar::WaitStatus - waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, - const Duration& duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) override; + Thread::CondVar::WaitStatus waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, + const Duration& duration) noexcept + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) override; // Event::TimeSystem Event::SchedulerPtr createScheduler(Scheduler& base_scheduler) override { diff --git a/test/test_common/test_time_system.h b/test/test_common/test_time_system.h index 449ec80653919..cb9ac3480215c 100644 --- a/test/test_common/test_time_system.h +++ b/test/test_common/test_time_system.h @@ -56,14 +56,15 @@ class TestTimeSystem : public Event::TimeSystem { * @param duration The maximum amount of time to wait. * @return Thread::CondVar::WaitStatus whether the condition timed out or not. */ - virtual Thread::CondVar::WaitStatus - waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, - const Duration& duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) PURE; + virtual Thread::CondVar::WaitStatus waitFor(Thread::MutexBasicLockable& mutex, + Thread::CondVar& condvar, + const Duration& duration) noexcept + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) PURE; template - Thread::CondVar::WaitStatus - waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, - const D& duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) { + Thread::CondVar::WaitStatus waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, + const D& duration) noexcept + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) { return waitFor(mutex, condvar, std::chrono::duration_cast(duration)); } }; @@ -108,9 +109,9 @@ template class DelegatingTestTimeSystemBase : public T timeSystem().advanceTimeWait(duration); } - Thread::CondVar::WaitStatus - waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, - const Duration& duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) override { + Thread::CondVar::WaitStatus waitFor(Thread::MutexBasicLockable& mutex, Thread::CondVar& condvar, + const Duration& duration) noexcept + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) override { return timeSystem().waitFor(mutex, condvar, duration); } diff --git a/tools/api_boost/api_boost.py b/tools/api_boost/api_boost.py index e644680e33927..8916e8b828227 100755 --- a/tools/api_boost/api_boost.py +++ b/tools/api_boost/api_boost.py @@ -44,7 +44,8 @@ def ApiBoostFile(llvm_include_path, debug_log, path): result = sp.run([ './bazel-bin/external/envoy_dev/clang_tools/api_booster/api_booster', '--extra-arg-before=-xc++', - '--extra-arg=-isystem%s' % llvm_include_path, '--extra-arg=-Wno-undefined-internal', path + '--extra-arg=-isystem%s' % llvm_include_path, '--extra-arg=-Wno-undefined-internal', + '--extra-arg=-Wno-old-style-cast', path ], capture_output=True, check=True) diff --git a/tools/clang_tools/README.md b/tools/clang_tools/README.md index a53ad6038af30..705138a7e3572 100644 --- a/tools/clang_tools/README.md +++ b/tools/clang_tools/README.md @@ -14,7 +14,7 @@ framework for writing Clang tools in the style of `clang-format` and To build tools in this tree, a Clang binary install must be available. If you are building Envoy with `clang`, this should already be true of your system. You can find prebuilt binary releases of Clang at https://releases.llvm.org. You -will need the Clang version used by Envoy in CI (currently clang-9.0). +will need the Clang version used by Envoy in CI (currently clang-10.0). To build a tool, set the following environment variable: diff --git a/tools/clang_tools/support/BUILD.prebuilt b/tools/clang_tools/support/BUILD.prebuilt index 277c9ad802f8f..e77dcb0fe2685 100644 --- a/tools/clang_tools/support/BUILD.prebuilt +++ b/tools/clang_tools/support/BUILD.prebuilt @@ -1,8 +1,8 @@ -# Clang 9.0 library pre-built Bazel. +# Clang 10.0 library pre-built Bazel. # # This file was mostly manually assembled (with some hacky Python scripts) from -# clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz and corresponding -# https://github.com/llvm/llvm-project.git source. It needs Clang 9.0 to work. +# clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz and corresponding +# https://github.com/llvm/llvm-project.git source. It needs Clang 10.0 to work. # # The BUILD file has sufficient dependency relationships # between the prebuilt libraries in a clang-llvm distribution to support building libtooling @@ -152,6 +152,7 @@ cc_library( ":clang_basic", ":clang_lex", ":clang_sema", + ":llvm_frontend_omp", ":llvm_mc", ":llvm_mcparser", ":llvm_support", @@ -306,6 +307,12 @@ cc_library( hdrs = glob(["llvm/Demangle/**"]), ) +cc_library( + name = "llvm_frontend_omp", + srcs = ["lib/libLLVMFrontendOpenMP.a"], + hdrs = glob(["llvm/Frontend/OpenMP/**"]), +) + cc_library( name = "llvm_mc", srcs = ["lib/libLLVMMC.a"], diff --git a/tools/clang_tools/support/clang_tools.bzl b/tools/clang_tools/support/clang_tools.bzl index a738fa57f28d4..949903aaff055 100644 --- a/tools/clang_tools/support/clang_tools.bzl +++ b/tools/clang_tools/support/clang_tools.bzl @@ -1,26 +1,31 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") +_clang_tools_copts = [ + "-std=c++14", + "-fno-exceptions", + "-fno-rtti", +] + def clang_tools_cc_binary(name, copts = [], tags = [], deps = [], **kwargs): cc_binary( name = name, - copts = copts + [ - "-fno-exceptions", - "-fno-rtti", - ], + copts = copts + _clang_tools_copts, tags = tags + ["manual"], deps = deps + ["@envoy//bazel/foreign_cc:zlib"], **kwargs ) -def clang_tools_cc_library(name, **kwargs): +def clang_tools_cc_library(name, copts = [], **kwargs): cc_library( name = name, + copts = copts + _clang_tools_copts, **kwargs ) -def clang_tools_cc_test(name, deps = [], **kwargs): +def clang_tools_cc_test(name, copts = [], deps = [], **kwargs): cc_test( name = name, + copts = copts + _clang_tools_copts, deps = deps + ["@com_google_googletest//:gtest_main"], **kwargs ) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 2dc4ed979f6d3..689ed09c7e5ba 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -87,7 +87,7 @@ # Only one C++ file should instantiate grpc_init GRPC_INIT_WHITELIST = ("./source/common/grpc/google_grpc_context.cc") -CLANG_FORMAT_PATH = os.getenv("CLANG_FORMAT", "clang-format-9") +CLANG_FORMAT_PATH = os.getenv("CLANG_FORMAT", "clang-format-10") BUILDIFIER_PATH = paths.getBuildifier() BUILDOZER_PATH = paths.getBuildozer() ENVOY_BUILD_FIXER_PATH = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), @@ -245,13 +245,13 @@ def checkTools(): "users".format(CLANG_FORMAT_PATH)) else: error_messages.append( - "Command {} not found. If you have clang-format in version 9.x.x " + "Command {} not found. If you have clang-format in version 10.x.x " "installed, but the binary name is different or it's not available in " "PATH, please use CLANG_FORMAT environment variable to specify the path. " "Examples:\n" - " export CLANG_FORMAT=clang-format-9.0.0\n" - " export CLANG_FORMAT=/opt/bin/clang-format-9\n" - " export CLANG_FORMAT=/usr/local/opt/llvm@9/bin/clang-format".format(CLANG_FORMAT_PATH)) + " export CLANG_FORMAT=clang-format-10.0.0\n" + " export CLANG_FORMAT=/opt/bin/clang-format-10\n" + " export CLANG_FORMAT=/usr/local/opt/llvm@10/bin/clang-format".format(CLANG_FORMAT_PATH)) def checkBazelTool(name, path, var): bazel_tool_abs_path = lookPath(path)