Merge pull request #6121 from nicolasnoble/upmerge

Upmerge from 0.13
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.c b/src/core/ext/transport/chttp2/transport/frame_data.c
index 9c301d1..3a6d80e 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.c
+++ b/src/core/ext/transport/chttp2/transport/frame_data.c
@@ -159,7 +159,10 @@
   }
 
   switch (p->state) {
-  fh_0:
+    case GRPC_CHTTP2_DATA_ERROR:
+      p->state = GRPC_CHTTP2_DATA_ERROR;
+      return GRPC_CHTTP2_STREAM_ERROR;
+    fh_0:
     case GRPC_CHTTP2_DATA_FH_0:
       stream_parsing->stats.incoming.framing_bytes++;
       p->frame_type = *cur;
@@ -172,6 +175,7 @@
           break;
         default:
           gpr_log(GPR_ERROR, "Bad GRPC frame type 0x%02x", p->frame_type);
+          p->state = GRPC_CHTTP2_DATA_ERROR;
           return GRPC_CHTTP2_STREAM_ERROR;
       }
       if (++cur == end) {
@@ -218,13 +222,11 @@
               message_flags, &p->incoming_frames);
     /* fallthrough */
     case GRPC_CHTTP2_DATA_FRAME:
-      if (cur == end) {
-        grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
-                                                 stream_parsing);
-        return GRPC_CHTTP2_PARSE_OK;
-      }
       grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
                                                stream_parsing);
+      if (cur == end) {
+        return GRPC_CHTTP2_PARSE_OK;
+      }
       uint32_t remaining = (uint32_t)(end - cur);
       if (remaining == p->frame_size) {
         stream_parsing->stats.incoming.data_bytes += p->frame_size;
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h
index 2ff3296..af71f48 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.h
+++ b/src/core/ext/transport/chttp2/transport/frame_data.h
@@ -49,7 +49,8 @@
   GRPC_CHTTP2_DATA_FH_2,
   GRPC_CHTTP2_DATA_FH_3,
   GRPC_CHTTP2_DATA_FH_4,
-  GRPC_CHTTP2_DATA_FRAME
+  GRPC_CHTTP2_DATA_FRAME,
+  GRPC_CHTTP2_DATA_ERROR
 } grpc_chttp2_stream_state;
 
 typedef struct grpc_chttp2_incoming_byte_stream
diff --git a/src/proto/gen_build_yaml.py b/src/proto/gen_build_yaml.py
index 8e66939..2a8d9fa 100755
--- a/src/proto/gen_build_yaml.py
+++ b/src/proto/gen_build_yaml.py
@@ -36,7 +36,7 @@
 import re
 import sys
 
-def update_deps(key, proto_filename, deps, is_trans, visited):
+def update_deps(key, proto_filename, deps, deps_external, is_trans, visited):
   if not proto_filename in visited:
     visited.append(proto_filename)
     with open(proto_filename) as inp:
@@ -44,10 +44,17 @@
         imp = re.search(r'import "([^"]*)"', line)
         if not imp: continue
         imp_proto = imp.group(1)
+        # This indicates an external dependency, which we should handle
+        # differently and not traverse recursively
+        if imp_proto.startswith('google/'):
+          if key not in deps_external:
+            deps_external[key] = []
+          deps_external[key].append(imp_proto[:-6])
+          continue
         if key not in deps: deps[key] = []
         deps[key].append(imp_proto[:-6])
         if is_trans:
-          update_deps(key, imp_proto, deps, is_trans, visited)
+          update_deps(key, imp_proto, deps, deps_external, is_trans, visited)
 
 def main():
   proto_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
@@ -55,17 +62,23 @@
 
   deps = {}
   deps_trans = {}
+  deps_external = {}
+  deps_external_trans = {}
   for root, dirs, files in os.walk('src/proto'):
     for f in files:
       if f[-6:] != '.proto': continue
       look_at = os.path.join(root, f)
       deps_for = look_at[:-6]
-      update_deps(deps_for, look_at, deps, False, [])      # First level deps
-      update_deps(deps_for, look_at, deps_trans, True, []) # Transitive deps
+      # First level deps
+      update_deps(deps_for, look_at, deps, deps_external, False, [])
+      # Transitive deps
+      update_deps(deps_for, look_at, deps_trans, deps_external_trans, True, [])
 
   json = {
     'proto_deps': deps,
-    'proto_transitive_deps': deps_trans
+    'proto_transitive_deps': deps_trans,
+    'proto_external_deps': deps_external,
+    'proto_transitive_external_deps': deps_external_trans
   }
 
   print yaml.dump(json)
diff --git a/templates/tools/dockerfile/test/sanity/Dockerfile.template b/templates/tools/dockerfile/test/sanity/Dockerfile.template
index 1baa9c8..8d6f52d 100644
--- a/templates/tools/dockerfile/test/sanity/Dockerfile.template
+++ b/templates/tools/dockerfile/test/sanity/Dockerfile.template
@@ -40,7 +40,8 @@
         automake ${"\\"}
         libtool ${"\\"}
         curl ${"\\"}
-        python-virtualenv
+        python-virtualenv ${"\\"}
+        python-lxml
   RUN pip install simplejson mako
 
   #===================
diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/9a6963b0d0fcb0e91a31748c47c6f0e1e842fea9 b/test/core/end2end/fuzzers/server_fuzzer_corpus/9a6963b0d0fcb0e91a31748c47c6f0e1e842fea9
new file mode 100644
index 0000000..e8fef7f
--- /dev/null
+++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/9a6963b0d0fcb0e91a31748c47c6f0e1e842fea9
Binary files differ
diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/a32be0653ccc65463445b4aaf24a7a1164d5c642 b/test/core/end2end/fuzzers/server_fuzzer_corpus/a32be0653ccc65463445b4aaf24a7a1164d5c642
new file mode 100644
index 0000000..a4c4bf3
--- /dev/null
+++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/a32be0653ccc65463445b4aaf24a7a1164d5c642
Binary files differ
diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-41ab0e868e84612275f77118f9e832bc94ff45c5 b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-41ab0e868e84612275f77118f9e832bc94ff45c5
new file mode 100644
index 0000000..87bfefb
--- /dev/null
+++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-41ab0e868e84612275f77118f9e832bc94ff45c5
Binary files differ
diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/fb84edfa9e8cbddba26a7184e7fdc219bde556c0 b/test/core/end2end/fuzzers/server_fuzzer_corpus/fb84edfa9e8cbddba26a7184e7fdc219bde556c0
new file mode 100644
index 0000000..f5de9d4
--- /dev/null
+++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/fb84edfa9e8cbddba26a7184e7fdc219bde556c0
Binary files differ
diff --git a/tools/distrib/check_vsprojects.py b/tools/distrib/check_vsprojects.py
new file mode 100755
index 0000000..96dd2e4
--- /dev/null
+++ b/tools/distrib/check_vsprojects.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python2.7
+
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import os
+import re
+import sys
+
+from lxml import etree
+
+
+def main():
+  root_dir = os.path.abspath(
+      os.path.join(os.path.dirname(sys.argv[0]), '../..'))
+  os.chdir(root_dir)
+
+  project_re = re.compile('Project\(.*\) = ".+", "(.+)", "(.+)"')
+
+  known_projects = {}
+  with open(os.path.join('vsprojects', 'grpc.sln')) as f:
+    for line in f.readlines():
+      m = project_re.match(line)
+      if not m:
+        continue
+
+      vcxproj_path, project_guid = m.groups()
+      if os.name != 'nt':
+        vcxproj_path = vcxproj_path.replace('\\', '/')
+
+      known_projects[project_guid] = vcxproj_path
+
+  ok = True
+  for vcxproj_path in known_projects.values():
+    with open(os.path.join(root_dir, 'vsprojects', vcxproj_path)) as f:
+      tree = etree.parse(f)
+
+    namespaces = {'ns': 'http://schemas.microsoft.com/developer/msbuild/2003'}
+    referenced_projects = tree.getroot().xpath('/ns:Project/ns:ItemGroup'
+                                               '/ns:ProjectReference'
+                                               '/ns:Project',
+                                               namespaces=namespaces)
+    for referenced_project in referenced_projects:
+      # Project tag under ProjectReference is a GUID reference.
+      if referenced_project.text not in known_projects:
+        target_vcxproj = referenced_project.getparent().attrib['Include']
+        guid = referenced_project.text
+        print ('In project "%s", dependency "%s" (with GUID "%s") is not in '
+               'grpc.sln' % (vcxproj_path, target_vcxproj, guid))
+        ok = False
+
+  if not ok:
+    exit(1)
+
+
+if __name__ == '__main__':
+  main()
+
diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile
index 5703215..3146a92 100644
--- a/tools/dockerfile/test/sanity/Dockerfile
+++ b/tools/dockerfile/test/sanity/Dockerfile
@@ -71,7 +71,8 @@
       automake \
       libtool \
       curl \
-      python-virtualenv
+      python-virtualenv \
+      python-lxml
 RUN pip install simplejson mako
 
 #===================
diff --git a/tools/http2_interop/http2interop.go b/tools/http2_interop/http2interop.go
index 1276a71..fa11396 100644
--- a/tools/http2_interop/http2interop.go
+++ b/tools/http2_interop/http2interop.go
@@ -150,7 +150,8 @@
 	}
 
 	// Write a bunch of invalid frame types.
-	for ft := ContinuationFrameType + 1; ft != 0; ft++ {
+	// Frame number 11 is the upcoming ALTSVC frame, and should not be tested.
+	for ft := ContinuationFrameType + 2; ft != 0; ft++ {
 		fh := &UnknownFrame{
 			Header: FrameHeader{
 				Type: ft,
diff --git a/tools/run_tests/sanity/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml
index f155c8d..efc21e6 100644
--- a/tools/run_tests/sanity/sanity_tests.yaml
+++ b/tools/run_tests/sanity/sanity_tests.yaml
@@ -5,6 +5,7 @@
 - script: tools/buildgen/generate_projects.sh -j 3
   cpu_cost: 3
 - script: tools/distrib/check_copyright.py
+- script: tools/distrib/check_vsprojects.py
 - script: tools/distrib/clang_format_code.sh
 - script: tools/distrib/check_trailing_newlines.sh
 - script: tools/distrib/check_nanopb_output.sh
diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json
index ebf8218..d6e40fe 100644
--- a/tools/run_tests/tests.json
+++ b/tools/run_tests/tests.json
@@ -50177,6 +50177,28 @@
   }, 
   {
     "args": [
+      "test/core/end2end/fuzzers/server_fuzzer_corpus/9a6963b0d0fcb0e91a31748c47c6f0e1e842fea9"
+    ], 
+    "ci_platforms": [
+      "linux", 
+      "mac", 
+      "windows", 
+      "posix"
+    ], 
+    "cpu_cost": 0.1, 
+    "exclude_configs": [], 
+    "flaky": false, 
+    "language": "c", 
+    "name": "server_fuzzer_one_entry", 
+    "platforms": [
+      "linux", 
+      "mac", 
+      "windows", 
+      "posix"
+    ]
+  }, 
+  {
+    "args": [
       "test/core/end2end/fuzzers/server_fuzzer_corpus/9bf7553a.bin"
     ], 
     "ci_platforms": [
@@ -50265,6 +50287,28 @@
   }, 
   {
     "args": [
+      "test/core/end2end/fuzzers/server_fuzzer_corpus/a32be0653ccc65463445b4aaf24a7a1164d5c642"
+    ], 
+    "ci_platforms": [
+      "linux", 
+      "mac", 
+      "windows", 
+      "posix"
+    ], 
+    "cpu_cost": 0.1, 
+    "exclude_configs": [], 
+    "flaky": false, 
+    "language": "c", 
+    "name": "server_fuzzer_one_entry", 
+    "platforms": [
+      "linux", 
+      "mac", 
+      "windows", 
+      "posix"
+    ]
+  }, 
+  {
+    "args": [
       "test/core/end2end/fuzzers/server_fuzzer_corpus/a357658d.bin"
     ], 
     "ci_platforms": [
@@ -51431,6 +51475,28 @@
   }, 
   {
     "args": [
+      "test/core/end2end/fuzzers/server_fuzzer_corpus/crash-41ab0e868e84612275f77118f9e832bc94ff45c5"
+    ], 
+    "ci_platforms": [
+      "linux", 
+      "mac", 
+      "windows", 
+      "posix"
+    ], 
+    "cpu_cost": 0.1, 
+    "exclude_configs": [], 
+    "flaky": false, 
+    "language": "c", 
+    "name": "server_fuzzer_one_entry", 
+    "platforms": [
+      "linux", 
+      "mac", 
+      "windows", 
+      "posix"
+    ]
+  }, 
+  {
+    "args": [
       "test/core/end2end/fuzzers/server_fuzzer_corpus/crash-7e121dd3be057176369bea160d873040b32a03dc"
     ], 
     "ci_platforms": [
@@ -52201,6 +52267,28 @@
   }, 
   {
     "args": [
+      "test/core/end2end/fuzzers/server_fuzzer_corpus/fb84edfa9e8cbddba26a7184e7fdc219bde556c0"
+    ], 
+    "ci_platforms": [
+      "linux", 
+      "mac", 
+      "windows", 
+      "posix"
+    ], 
+    "cpu_cost": 0.1, 
+    "exclude_configs": [], 
+    "flaky": false, 
+    "language": "c", 
+    "name": "server_fuzzer_one_entry", 
+    "platforms": [
+      "linux", 
+      "mac", 
+      "windows", 
+      "posix"
+    ]
+  }, 
+  {
+    "args": [
       "test/core/end2end/fuzzers/server_fuzzer_corpus/fd14bea45ecaf13af0053900edb2f17b71a0bf09"
     ], 
     "ci_platforms": [