Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http inspector: use http_parser in http inspector #8808

Merged
merged 9 commits into from
Nov 3, 2019
Merged

Conversation

yxue
Copy link
Contributor

@yxue yxue commented Oct 30, 2019

Signed-off-by: crazyxy yxyan@google.com

Description: use http_parser in http inspector
Risk Level: Med
Testing: Unit test
Docs Changes: N/A
Release Notes: N/A
[Optional Fixes #Issue]
[Optional Deprecated:]

Signed-off-by: crazyxy <yxyan@google.com>
@moderation
Copy link
Contributor

Considering that http-parser needs to be replaced (#5155) should we increase its usage? Or will this code be portable / usable by llhttp (if that is what we use to replace http-parser)?

@yxue
Copy link
Contributor Author

yxue commented Oct 30, 2019

The problem here is that current parsing logic in http inspector is different from http-parser. There might be some case that traffic is detected as non http, but http-parser can parse successfully, e.g.

GET  /index  HTTP/1.1
   ^ two spaces

I didn't do investigation and don't know if llhttp will give the same result as http-parser when inspecting the incoming packets and I think we need to migrate this code to llhttp when http-parser is completely replaced by llhttp for http/1x codec.

@lizan
Copy link
Member

lizan commented Oct 30, 2019

@moderation we can migrate both place to llhttp later if that's the choice, at this point the focus of this PR is use same parser so we get consistent result. llhttp has pretty similar interface to http_parser so increasing usage here shouldn't affect too much on migration.

Signed-off-by: crazyxy <yxyan@google.com>
@yxue yxue marked this pull request as ready for review October 30, 2019 23:02
@yxue yxue requested a review from lizan as a code owner October 30, 2019 23:02
@@ -108,6 +128,7 @@ ParseState Filter::onRead() {

Copy link
Contributor

Choose a reason for hiding this comment

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

Using MSG_PEEK repetitively leads to O(N^2) cost if the attacker sends 1 byte messages. The 8K limit is AFAICT only for Apache, other servers can accept longer URLs.

In many cases a URL can be padded out in a way that the server will still accept, for example by providing unnecessary query key-value pairs. This makes it possible to fool the parser and still have the URL accepted by the backend.

You can also use a callback to abort further parsing in on_headers_complete by returning an error and checking for CB_headers_complete failure before declaring a ParseState::Error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR to validate the request line only as discussed in the below comment.

Signed-off-by: crazyxy <yxyan@google.com>
Signed-off-by: crazyxy <yxyan@google.com>
@yxue
Copy link
Contributor Author

yxue commented Oct 31, 2019

Hmm.. I added a test for larger request line and the test failed under both asan and tasn.

asan failed with error

    #0 0x3a01c39 in BufferedStackTrace /local/mnt/workspace/bcain_clang_bcain-ubuntu_23113/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_stacktrace.h:98:37
    #1 0x3a01c39 in free /local/mnt/workspace/bcain_clang_bcain-ubuntu_23113/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:123:3
    #2 0x3b9a7b0 in testing::internal::AnyMatcherImpl<std::tuple<int, void*, unsigned long, int> const&>::~AnyMatcherImpl() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-matchers.h:492:7
    #3 0x3b9b5c0 in std::_Sp_counted_ptr<testing::MatcherInterface<std::tuple<int, void*, unsigned long, int> const&> const*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:376:9
    #4 0x3af35b6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:154:6
    #5 0x3af33e7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:684:11
    #6 0x3b9b87d in std::__shared_ptr<testing::MatcherInterface<std::tuple<int, void*, unsigned long, int> const&> const, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:1123:31
    #7 0x3b9b817 in std::shared_ptr<testing::MatcherInterface<std::tuple<int, void*, unsigned long, int> const&> const>::~shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr.h:93:11
    #8 0x3b9acb6 in testing::internal::MatcherBase<std::tuple<int, void*, unsigned long, int> const&>::~MatcherBase() /proc/self/cwd/external/com_google_googletest/googletest/include/gtest/gtest-matchers.h:311:27
    #9 0x3b99687 in testing::Matcher<std::tuple<int, void*, unsigned long, int> const&>::~Matcher() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:52:7
    #10 0x3b99d15 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:910:3
    #11 0x3b99e14 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:902:32
    #12 0x3b9c660 in std::_Sp_counted_ptr<testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:376:9
    #13 0x3af35b6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:154:6
    #14 0x3af33e7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:684:11
    #15 0x3b35a1d in std::__shared_ptr<testing::internal::ExpectationBase, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:1123:31
    #16 0x3b2bcc7 in std::shared_ptr<testing::internal::ExpectationBase>::~shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr.h:93:11
    #17 0x995ac74 in testing::Expectation::~Expectation() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:849:30
    #18 0x3d80c6d in void __gnu_cxx::new_allocator<std::_Rb_tree_node<testing::Expectation> >::destroy<testing::Expectation>(testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/ext/new_allocator.h:140:28
    #19 0x3d80a79 in void std::allocator_traits<std::allocator<std::_Rb_tree_node<testing::Expectation> > >::destroy<testing::Expectation>(std::allocator<std::_Rb_tree_node<testing::Expectation> >&, testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/alloc_traits.h:487:8
    #20 0x3d80958 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_destroy_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:650:2
    #21 0x3d8086c in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_drop_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:658:2
    #22 0x3d803d0 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_erase(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:1858:4
    #23 0x3d80280 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::~_Rb_tree() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:949:9
    #24 0x3d80214 in std::set<testing::Expectation, testing::Expectation::Less, std::allocator<testing::Expectation> >::~set() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_set.h:271:22
    #25 0x3d7dd94 in testing::ExpectationSet::~ExpectationSet() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:571:7
    #26 0x994964a in testing::internal::ExpectationBase::~ExpectationBase() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:94:38
    #27 0x3b99d33 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:910:3
    #28 0x3b99e14 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:902:32
    #29 0x3b9c660 in std::_Sp_counted_ptr<testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:376:9
    #30 0x3af35b6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:154:6
    #31 0x3af33e7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:684:11
    #32 0x3b35a1d in std::__shared_ptr<testing::internal::ExpectationBase, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:1123:31
    #33 0x3b2bcc7 in std::shared_ptr<testing::internal::ExpectationBase>::~shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr.h:93:11
    #34 0x995ac74 in testing::Expectation::~Expectation() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:849:30
    #35 0x3d80c6d in void __gnu_cxx::new_allocator<std::_Rb_tree_node<testing::Expectation> >::destroy<testing::Expectation>(testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/ext/new_allocator.h:140:28
    #36 0x3d80a79 in void std::allocator_traits<std::allocator<std::_Rb_tree_node<testing::Expectation> > >::destroy<testing::Expectation>(std::allocator<std::_Rb_tree_node<testing::Expectation> >&, testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/alloc_traits.h:487:8
    #37 0x3d80958 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_destroy_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:650:2
    #38 0x3d8086c in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_drop_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:658:2
    #39 0x3d803d0 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_erase(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:1858:4
    #40 0x3d80280 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::~_Rb_tree() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:949:9
    #41 0x3d80214 in std::set<testing::Expectation, testing::Expectation::Less, std::allocator<testing::Expectation> >::~set() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_set.h:271:22
    #42 0x3d7dd94 in testing::ExpectationSet::~ExpectationSet() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:571:7
    #43 0x994964a in testing::internal::ExpectationBase::~ExpectationBase() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:94:38
    #44 0x3b99d33 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:910:3
    #45 0x3b99e14 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:902:32
    #46 0x3b9c660 in std::_Sp_counted_ptr<testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:376:9
    #47 0x3af35b6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:154:6
    #48 0x3af33e7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:684:11
    #49 0x3b35a1d in std::__shared_ptr<testing::internal::ExpectationBase, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:1123:31
    #50 0x3b2bcc7 in std::shared_ptr<testing::internal::ExpectationBase>::~shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr.h:93:11
    #51 0x995ac74 in testing::Expectation::~Expectation() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:849:30
    #52 0x3d80c6d in void __gnu_cxx::new_allocator<std::_Rb_tree_node<testing::Expectation> >::destroy<testing::Expectation>(testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/ext/new_allocator.h:140:28
    #53 0x3d80a79 in void std::allocator_traits<std::allocator<std::_Rb_tree_node<testing::Expectation> > >::destroy<testing::Expectation>(std::allocator<std::_Rb_tree_node<testing::Expectation> >&, testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/alloc_traits.h:487:8
    #54 0x3d80958 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_destroy_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:650:2
    #55 0x3d8086c in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_drop_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:658:2
    #56 0x3d803d0 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_erase(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:1858:4
    #57 0x3d80280 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::~_Rb_tree() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:949:9
    #58 0x3d80214 in std::set<testing::Expectation, testing::Expectation::Less, std::allocator<testing::Expectation> >::~set() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_set.h:271:22
    #59 0x3d7dd94 in testing::ExpectationSet::~ExpectationSet() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:571:7
    #60 0x994964a in testing::internal::ExpectationBase::~ExpectationBase() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:94:38
    #61 0x3b99d33 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:910:3
    #62 0x3b99e14 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:902:32
    #63 0x3b9c660 in std::_Sp_counted_ptr<testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:376:9
    #64 0x3af35b6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:154:6
    #65 0x3af33e7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:684:11
    #66 0x3b35a1d in std::__shared_ptr<testing::internal::ExpectationBase, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:1123:31
    #67 0x3b2bcc7 in std::shared_ptr<testing::internal::ExpectationBase>::~shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr.h:93:11
    #68 0x995ac74 in testing::Expectation::~Expectation() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:849:30
    #69 0x3d80c6d in void __gnu_cxx::new_allocator<std::_Rb_tree_node<testing::Expectation> >::destroy<testing::Expectation>(testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/ext/new_allocator.h:140:28
    #70 0x3d80a79 in void std::allocator_traits<std::allocator<std::_Rb_tree_node<testing::Expectation> > >::destroy<testing::Expectation>(std::allocator<std::_Rb_tree_node<testing::Expectation> >&, testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/alloc_traits.h:487:8
    #71 0x3d80958 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_destroy_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:650:2
    #72 0x3d8086c in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_drop_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:658:2
    #73 0x3d803d0 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_erase(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:1858:4
    #74 0x3d80280 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::~_Rb_tree() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:949:9
    #75 0x3d80214 in std::set<testing::Expectation, testing::Expectation::Less, std::allocator<testing::Expectation> >::~set() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_set.h:271:22
    #76 0x3d7dd94 in testing::ExpectationSet::~ExpectationSet() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:571:7
    #77 0x994964a in testing::internal::ExpectationBase::~ExpectationBase() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:94:38
    #78 0x3b99d33 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:910:3
    #79 0x3b99e14 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:902:32
    #80 0x3b9c660 in std::_Sp_counted_ptr<testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:376:9
    #81 0x3af35b6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:154:6
    #82 0x3af33e7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:684:11
    #83 0x3b35a1d in std::__shared_ptr<testing::internal::ExpectationBase, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:1123:31
    #84 0x3b2bcc7 in std::shared_ptr<testing::internal::ExpectationBase>::~shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr.h:93:11
    #85 0x995ac74 in testing::Expectation::~Expectation() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:849:30
    #86 0x3d80c6d in void __gnu_cxx::new_allocator<std::_Rb_tree_node<testing::Expectation> >::destroy<testing::Expectation>(testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/ext/new_allocator.h:140:28
    #87 0x3d80a79 in void std::allocator_traits<std::allocator<std::_Rb_tree_node<testing::Expectation> > >::destroy<testing::Expectation>(std::allocator<std::_Rb_tree_node<testing::Expectation> >&, testing::Expectation*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/alloc_traits.h:487:8
    #88 0x3d80958 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_destroy_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:650:2
    #89 0x3d8086c in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_drop_node(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:658:2
    #90 0x3d803d0 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::_M_erase(std::_Rb_tree_node<testing::Expectation>*) /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:1858:4
    #91 0x3d80280 in std::_Rb_tree<testing::Expectation, testing::Expectation, std::_Identity<testing::Expectation>, testing::Expectation::Less, std::allocator<testing::Expectation> >::~_Rb_tree() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_tree.h:949:9
    #92 0x3d80214 in std::set<testing::Expectation, testing::Expectation::Less, std::allocator<testing::Expectation> >::~set() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_set.h:271:22
    #93 0x3d7dd94 in testing::ExpectationSet::~ExpectationSet() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:571:7
    #94 0x994964a in testing::internal::ExpectationBase::~ExpectationBase() /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:94:38
    #95 0x3b99d33 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:910:3
    #96 0x3b99e14 in testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>::~TypedExpectation() /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:902:32
    #97 0x3b9c660 in std::_Sp_counted_ptr<testing::internal::TypedExpectation<Envoy::Api::SysCallResult<long> (int, void*, unsigned long, int)>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:376:9
    #98 0x3af35b6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:154:6
    #99 0x3af33e7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:684:11
    #100 0x3b35a1d in std::__shared_ptr<testing::internal::ExpectationBase, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/shared_ptr_base.h:1123:31
...

tsan failed silently

Working on it

Signed-off-by: crazyxy <yxyan@google.com>
@yxue
Copy link
Contributor Author

yxue commented Nov 1, 2019

It seems the ci failure is not related with the PR

Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

http_parser support stream interface
The semantic of http_parser_execute is feeding new data.

We should use the assumption that the data we peek last time should remain the same. Suppose last time we see 6k data, and this time we see 8k, we should feed the slice of (6k, 8k) using http_parser_execute(&parser_/last state/, &setting_, request_line.data() + 6k, request_line.length()-6k);

Signed-off-by: Yan Xue <yxyan@google.com>
.WillOnce(
Invoke([&data, len](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult {
ASSERT(length >= data.size());
memcpy(buffer, data.data(), data.size());
Copy link
Member

Choose a reason for hiding this comment

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

len instead of data.size()? (ditto for below)

Copy link
Member

Choose a reason for hiding this comment

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

@yxue I meant len here exactly 😅to copy less memory, not size() vs length().

Copy link
Contributor Author

@yxue yxue Nov 2, 2019

Choose a reason for hiding this comment

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

😳 let me change it back

Signed-off-by: Yan Xue <yxyan@google.com>
Signed-off-by: crazyxy <yxyan@google.com>
Signed-off-by: crazyxy <yxyan@google.com>
@lizan lizan merged commit 3c2f5d6 into envoyproxy:master Nov 3, 2019
PiotrSikora pushed a commit to PiotrSikora/envoy that referenced this pull request Nov 9, 2019
Description: use http_parser in http inspector
Risk Level: Med
Testing: Unit test
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: crazyxy <yxyan@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
howardjohn pushed a commit to istio/envoy that referenced this pull request Nov 9, 2019
…120)

Description: use http_parser in http inspector
Risk Level: Med
Testing: Unit test
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: crazyxy <yxyan@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants