Skip to content

build(deps): bump abseil-cpp to latest version#24386

Merged
yanavlasov merged 9 commits intomainfrom
builddeps-bump-abseil-cpp-to-latest-version
Dec 13, 2022
Merged

build(deps): bump abseil-cpp to latest version#24386
yanavlasov merged 9 commits intomainfrom
builddeps-bump-abseil-cpp-to-latest-version

Conversation

@jpsim
Copy link
Copy Markdown
Contributor

@jpsim jpsim commented Dec 6, 2022

This also allows us to remove the mobile override and its patch because the new version of abseil-cpp pulls in google/cctz#237.

Fixes envoyproxy/envoy-mobile#136.

Commit Message:
Additional Description:
Risk Level: Moderate, bumping a core dependency
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
Fixes: envoyproxy/envoy-mobile#136

@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #24386 was opened by jpsim.

see: more, trace.

This also allows us to remove the mobile override and its patch because
the new version of abseil-cpp pulls in
google/cctz#237.

Fixes envoyproxy/envoy-mobile#136.

Signed-off-by: JP Simard <jp@jpsim.com>
@jpsim jpsim force-pushed the builddeps-bump-abseil-cpp-to-latest-version branch from c1f0745 to c3b344e Compare December 6, 2022 16:45
@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Dec 6, 2022
@jpsim jpsim marked this pull request as ready for review December 6, 2022 16:45
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/mobile-maintainers: FYI only for changes made to (mobile/).
envoyproxy/mobile-maintainers assignee is @abeyad
CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @phlax

🐱

Caused by: #24386 was opened by jpsim.

see: more, trace.

@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 6, 2022

/assign @alyssawilk

alyssawilk
alyssawilk previously approved these changes Dec 6, 2022
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, ci-willing :-)

Signed-off-by: JP Simard <jp@jpsim.com>
@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 6, 2022

ci-willing :-)

CI was not willing :(

Had to 2022-12-06 -> 2022-12-05

@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 6, 2022

asan is also not willing: https://github.com/envoyproxy/envoy/actions/runs/3631831474/jobs/6127137584

external/envoy/source/common/http/status.cc:64:10: runtime error: reference binding to misaligned address 0x60600030ece9 for type 'const Envoy::Http::(anonymous namespace)::EnvoyStatusPayload', which requires 4 byte alignment
0x60600030ece9: note: pointer points here
 00 00 00  08 01 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00
              ^ 
    #0 0x665c134 in Envoy::Http::getStatusCode(absl::Status const&) ??:?
    #1 0x665dbd8 in Envoy::Http::isPrematureResponseError(absl::Status const&) ??:?
    #2 0x4ddd757 in Envoy::Http::CodecClient::onData(Envoy::Buffer::Instance&) ??:?
    #3 0x4de5c68 in Envoy::Http::CodecClient::CodecReadFilter::onData(Envoy::Buffer::Instance&, bool) ??:?
    #4 0x61aef17 in Envoy::Network::FilterManagerImpl::onContinueReading(Envoy::Network::FilterManagerImpl::ActiveReadFilter*, Envoy::Network::ReadBufferSource&) ??:?
    #5 0x61af5ba in Envoy::Network::FilterManagerImpl::onRead() ??:?
    #6 0x6185f5a in Envoy::Network::ConnectionImpl::onRead(unsigned long) ??:?
    #7 0x6197f1a in Envoy::Network::ConnectionImpl::onReadReady() ??:?
    #8 0x619024c in Envoy::Network::ConnectionImpl::onFileEvent(unsigned int) ??:?
    #9 0x61a31f2 in std::_Function_handler<void (unsigned int), Envoy::Network::ConnectionImpl::ConnectionImpl(Envoy::Event::Dispatcher&, std::unique_ptr<Envoy::Network::ConnectionSocket, std::default_delete<Envoy::Network::ConnectionSocket> >&&, std::unique_ptr<Envoy::Network::TransportSocket, std::default_delete<Envoy::Network::TransportSocket> >&&, Envoy::StreamInfo::StreamInfo&, bool)::$_6>::_M_invoke(std::_Any_data const&, unsigned int&&) connection_impl.cc:?
    #10 0x382aae8 in std::function<void (unsigned int)>::operator()(unsigned int) const ??:?
    #11 0x6123661 in std::_Function_handler<void (unsigned int), Envoy::Event::DispatcherImpl::createFileEvent(int, std::function<void (unsigned int)>, Envoy::Event::FileTriggerType, unsigned int)::$_5>::_M_invoke(std::_Any_data const&, unsigned int&&) dispatcher_impl.cc:?
    #12 0x382aae8 in std::function<void (unsigned int)>::operator()(unsigned int) const ??:?
    #13 0x6132cad in Envoy::Event::FileEventImpl::mergeInjectedEventsAndRunCb(unsigned int) ??:?
    #14 0x6133346 in Envoy::Event::FileEventImpl::assignEvents(unsigned int, event_base*)::$_1::__invoke(int, short, void*) file_event_impl.cc:?
    #15 0x6cdf600 in event_process_active_single_queue event.c:?
    #16 0x6cbfe52 in event_base_loop ??:?
    #17 0x650a42e in Envoy::Event::LibeventScheduler::run(Envoy::Event::Dispatcher::RunType) ??:?
    #18 0x611cff8 in Envoy::Event::DispatcherImpl::run(Envoy::Event::Dispatcher::RunType) ??:?
    #19 0x422cf5f in Envoy::Server::InstanceImpl::run() ??:?
    #20 0x2d27508 in Envoy::MainCommonBase::run() ??:?
    #21 0x2d02def in Envoy::Engine::main(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) ??:?
    #22 0x2d191c4 in envoy_status_t std::__invoke_impl<envoy_status_t, envoy_status_t (Envoy::Engine::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), Envoy::Engine*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__invoke_memfun_deref, envoy_status_t (Envoy::Engine::*&&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), Envoy::Engine*&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) ??:?
    #23 0x2d18fc8 in std::__invoke_result<envoy_status_t (Envoy::Engine::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), Envoy::Engine*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::type std::__invoke<envoy_status_t (Envoy::Engine::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), Envoy::Engine*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(envoy_status_t (Envoy::Engine::*&&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), Envoy::Engine*&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) ??:?
    #24 0x2d18fa5 in envoy_status_t std::thread::_Invoker<std::tuple<envoy_status_t (Envoy::Engine::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), Envoy::Engine*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::_M_invoke<0ul, 1ul, 2ul, 3ul, 4ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul, 4ul>) ??:?
    #25 0x2d18dec in std::thread::_State_impl<std::thread::_Invoker<std::tuple<envoy_status_t (Envoy::Engine::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), Envoy::Engine*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::_M_run() ??:?
    #26 0x7f584fe98de3 in std::error_code::default_error_condition() const ??:?
    #27 0x7f584fda7608 in start_thread ??:?
    #28 0x7f584fb60132 in clone ??:?

@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 7, 2022

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #24386 (comment) was created by @jpsim.

see: more, trace.

@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 7, 2022

I've spun up a Linux EC2 instance to try to reproduce the asan failures. Maybe that'll let me bisect the abseil changes and pinpoint the change that's causing this asan failure.

image

@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 8, 2022

I was able to bisect the asan failure to this commit: abseil/abseil-cpp@91b7cd6

jpsim added 2 commits December 7, 2022 22:19
…-cpp-to-latest-version

* origin/main: (23 commits)
  Reduce Route memory utilization by avoiding RuntimeData instances when not needed (#24327)
  build: fix compile error for mac (#24429)
  postgres: support for upstream SSL (#23990)
  iOS: split `EnvoyEngine.h` into multiple header files (#24397)
  mobile: check for pending exceptions after JNI call (#24361)
  Remove uneccessary `this->` from mobile engine builder (#24389)
  Add setRequestDecoder to ResponseEncoder interface (#24368)
  downstream: refactoring code to remove listener hard deps (#24394)
  lb api: moving load balancing policy specific configuration to extension configuration (#23967)
  ci: Skip docker/examples verification for docs or mobile only changes (#24417)
  ci: run mobile GitHub Actions on every PR (#24407)
  mobile: remove `bump_lyft_support_rotation.sh` script (#24404)
  Add file size to DirectoryEntry (#24176)
  bazel: update to 6.0.0rc4 (#24235)
  bazel: update rules_rust (#24409)
  Ecds config dump recommit (#24384)
  bazel: add another config_setting incompatible flag (#24270)
  listeners: moving listeners to extension directory (#24248)
  mobile: build Swift with whole module optimization (#24396)
  ci: update `actions/setup-java` from v1 to v3.8 (#24393)
  ...

Signed-off-by: JP Simard <jp@jpsim.com>
I'm hoping that abseil/abseil-cpp@5736d76
fixes the asan failure we're seeing.

Signed-off-by: JP Simard <jp@jpsim.com>
@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 8, 2022

I filed abseil/abseil-cpp#1339 to report the undefined behavior error reported in sanitizer CI jobs.

@derekmauro
Copy link
Copy Markdown
Contributor

derekmauro commented Dec 8, 2022

I filed abseil/abseil-cpp#1339 to report the undefined behavior error reported in sanitizer CI jobs.

template <typename T> void storePayload(absl::Status& status, const T& payload) {
absl::Cord cord(absl::string_view(reinterpret_cast<const char*>(&payload), sizeof(payload)));
cord.Flatten(); // Flatten ahead of time for easier access later.
status.SetPayload(EnvoyPayloadUrl, std::move(cord));
}
template <typename T = EnvoyStatusPayload> const T& getPayload(const absl::Status& status) {
// The only way to get a reference to the payload owned by the absl::Status is through the
// ForEachPayload method. All other methods create a copy of the payload, which is not convenient
// for peeking at the payload value.
const T* payload = nullptr;
status.ForEachPayload([&payload](absl::string_view url, const absl::Cord& cord) {
if (url == EnvoyPayloadUrl) {
ASSERT(!payload); // Status API guarantees to have one payload with given URL
auto data = cord.TryFlat();
ASSERT(data.has_value()); // EnvoyPayloadUrl cords are flattened ahead of time
ASSERT(data.value().length() >= sizeof(T), "Invalid payload length");
payload = reinterpret_cast<const T*>(data.value().data());
}
});
ASSERT(payload);
return *payload;
}

The bug is in the reinterpret_cast in this code. The reinterpret_cast assumes the data is pointer-aligned. Instead the data needs to be read/written using memcpy or something endian-neutral if it is sent over the wire.

@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 8, 2022

The bug is in the reinterpret_cast in this code. The reinterpret_cast assumes the data is pointer-aligned. Instead the data needs to be read/written using memcpy or something endian-neutral if it is sent over the wire.

Correct me if I'm wrong, but wouldn't that incur the cost of a copy where the current code doesn't?

@derekmauro
Copy link
Copy Markdown
Contributor

derekmauro commented Dec 8, 2022

The bug is in the reinterpret_cast in this code. The reinterpret_cast assumes the data is pointer-aligned. Instead the data needs to be read/written using memcpy or something endian-neutral if it is sent over the wire.

Correct me if I'm wrong, but wouldn't that incur the cost of a copy where the current code doesn't?

A copy is already being made in storePayload(). If you really want to play games, perhaps you could new a copy of the object in storePayload(), and then construct the absl::Cord using absl::MakeCordFromExternal(). This is only worth it if objects are large.

Signed-off-by: JP Simard <jp@jpsim.com>
@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 8, 2022

A copy is already being made in storePayload(). If you really want to play games, perhaps you could new a copy of the object in storePayload(), and then construct the absl::Cord using absl::MakeCordFromExternal(). This is only worth it if objects are large.

Thanks for the suggestion. I'm not trying to play games, just trying to do things correctly here without unreasonably regressing behavior or performance here. I've made an attempt to switch to memcpy in my latest commit and will see if that satisfies the sanitizers.

Signed-off-by: JP Simard <jp@jpsim.com>
@alyssawilk
Copy link
Copy Markdown
Contributor

/wait on CI

@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Dec 12, 2022

@yanavlasov could you please take a look?

const size_t payload_size = sizeof(payload);
char* buffer = new char[payload_size];
safeMemcpyUnsafeDst(buffer, &payload);
absl::Cord cord(absl::string_view(buffer, payload_size));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to this function do not solve any problem. I think the only change needed is something like this:

template <typename T> void storePayload(absl::Status& status, const T& payload) {
  const T* allocated = new T(payload);
  absl::Cord cord = absl::MakeCordFromExternal(absl::string_view(&allocated, sizeof(allocated)), [allocated]() { delete allocated; });
  status.SetPayload(EnvoyPayloadUrl, std::move(cord));
}

Then getPayload should not have to change at all since the object will already be correctly aligned.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Seems like absl::string_view() expects a char * as its first argument, but here we have a T*.

source/common/http/status.cc:46:48: error: no matching constructor for initialization of 'absl::string_view'
  absl::Cord cord = absl::MakeCordFromExternal(absl::string_view(&allocated, sizeof(allocated)), [allocated]() { delete allocated; });
                                               ^                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is safe to cast to const char *.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, trying that now in 68c52cf

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the tests pass with the latest changes, including with the address and undefined behavior sanitizers.

Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
const T* allocated = new T(payload);
const absl::string_view sv =
absl::string_view(reinterpret_cast<const char*>(allocated), sizeof(allocated));
absl::Cord cord = absl::MakeCordFromExternal(sv, [allocated]() { delete allocated; });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trusting proto folks and our tests for correctness here :-P

@yanavlasov yanavlasov merged commit 9dcf001 into main Dec 13, 2022
@jpsim jpsim deleted the builddeps-bump-abseil-cpp-to-latest-version branch December 13, 2022 20:40
jpsim added a commit that referenced this pull request Dec 14, 2022
…-tools

* origin/main: (59 commits)
  Make IsOkAndHolds matcher work with submatchers (#24498)
  ios: fix platform key value store (#24532)
  make ClusterInfo::traffic_stats_ a unique_ptr, so that later we can lazy-init it later. (#24406)
  quic: splitting into client and server (#24513)
  fixing coverage (#24529)
  ci: Add `examplesOnly` condition (#24465)
  ci: sonatype_nexus_upload.py: remove unused format argument (#24471)
  deps: Bump `build_bazel_rules_apple` -> 1.1.3 (#24527)
  deps: Bump `com_github_nghttp2_nghttp2` -> 1.51.0 (#24525)
  deps: Bump `rules_license` -> 0.0.4 (#24523)
  build(deps): bump sphinxcontrib-httpdomain from 1.8.0 to 1.8.1 in /mobile/docs (#24126)
  build(deps): bump github/codeql-action from 2.1.35 to 2.1.36 (#24473)
  build(deps): bump openpolicyagent/opa from 0.47.2-istio to 0.47.3-istio in /examples/ext_authz (#24514)
  build(deps): bump node from `80844b6` to `2770c78` in /examples/ext_authz/auth/http-service (#24515)
  build(deps): bump abseil-cpp to latest version (#24386)
  xDS: add xDS config tracker extension point (#23485)
  kafka: add shared consumer manager (#24494)
  coverage: Improve test coverage (#24355)
  deps: Bump `rules_python` -> 0.16.1 (#24344)
  ci: revert disable running the Objective-C integration app (#24478)" (#24496)
  ...

Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies mobile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bazel: remove abseil workaround

6 participants