From 3f4bad0557fb8c2f6b9f68f99cb9f24c76a34421 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Fri, 23 Oct 2020 11:16:35 -0700 Subject: [PATCH 1/2] cel: patch thread safety issue Signed-off-by: Kuat Yessenov --- bazel/cel-cpp.patch | 33 +++++++++++++++++++++++++++++++++ bazel/repositories.bzl | 7 ++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 bazel/cel-cpp.patch diff --git a/bazel/cel-cpp.patch b/bazel/cel-cpp.patch new file mode 100644 index 000000000000..aa8d795b1410 --- /dev/null +++ b/bazel/cel-cpp.patch @@ -0,0 +1,33 @@ +diff --git a/eval/eval/field_backed_map_impl.cc b/eval/eval/field_backed_map_impl.cc +index cd56f51..4d2a546 100644 +--- a/eval/eval/field_backed_map_impl.cc ++++ b/eval/eval/field_backed_map_impl.cc +@@ -117,7 +117,9 @@ int FieldBackedMapImpl::size() const { + const CelList* FieldBackedMapImpl::ListKeys() const { return key_list_.get(); } + + absl::optional FieldBackedMapImpl::operator[](CelValue key) const { +-#ifdef GOOGLE_PROTOBUF_HAS_CEL_MAP_REFLECTION_FRIEND ++#ifdef XXX_GOOGLE_PROTOBUF_HAS_CEL_MAP_REFLECTION_FRIEND ++ static_assert(false); ++ + // Fast implementation. + google::protobuf::MapKey inner_key; + switch (key.type()) { +@@ -171,7 +173,7 @@ absl::optional FieldBackedMapImpl::operator[](CelValue key) const { + return CreateErrorValue(arena_, status.message()); + } + return result; +-#else // GOOGLE_PROTOBUF_HAS_CEL_MAP_REFLECTION_FRIEND ++#else // XXX_GOOGLE_PROTOBUF_HAS_CEL_MAP_REFLECTION_FRIEND + // Slow implementation. + CelValue result = CelValue::CreateNull(); + CelValue inner_key = CelValue::CreateNull(); +@@ -228,7 +230,7 @@ absl::optional FieldBackedMapImpl::operator[](CelValue key) const { + } + + return {}; +-#endif // GOOGLE_PROTOBUF_HAS_CEL_MAP_REFLECTION_FRIEND ++#endif // XXX_GOOGLE_PROTOBUF_HAS_CEL_MAP_REFLECTION_FRIEND + } + + } // namespace runtime diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 0ca0d5186e92..31e24a869fa9 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -348,7 +348,12 @@ def _com_github_zlib_ng_zlib_ng(): ) def _com_google_cel_cpp(): - external_http_archive("com_google_cel_cpp") + external_http_archive( + "com_google_cel_cpp", + patch_args = ["-p1"], + # Patches to remove "fast" protobuf-internal access + patches = ["@envoy//bazel:cel-cpp.patch"], + ) external_http_archive("rules_antlr") # Parser dependencies From b168d80ef2c12a030452e8e001d602e2c3c434ac Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Tue, 27 Oct 2020 12:41:52 -0700 Subject: [PATCH 2/2] explanation Signed-off-by: Kuat Yessenov --- bazel/repositories.bzl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 20ece890e017..3df6e8313bd9 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -352,6 +352,9 @@ def _com_google_cel_cpp(): "com_google_cel_cpp", patch_args = ["-p1"], # Patches to remove "fast" protobuf-internal access + # The patch can be removed when the "fast" access is safe to be enabled back. + # This requires public visibility of Reflection::LookupMapValue in protobuf and + # any release of cel-cpp after 10/27/2020. patches = ["@envoy//bazel:cel-cpp.patch"], ) external_http_archive("rules_antlr")