Add Win UBSAN jobs.

Bug: skia:2679
Change-Id: Ia462af01b9832da90206b9e9be2278cb48c6c502
Reviewed-on: https://skia-review.googlesource.com/86401
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Ben Wagner <benjaminwagner@google.com>
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 52c0838..c94d237 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -206,13 +206,22 @@
     # You can either pass the sanitizers directly, e.g. "address,undefined",
     # or pass one of the couple common aliases used by the bots.
     sanitizers = sanitize
-    if (sanitize == "ASAN") {
-      sanitizers = "address,bool,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
-      if (!is_mac) {
-        sanitizers += ",function"  # Not supported on Mac.
+    if (sanitize == "ASAN" || sanitize == "UBSAN") {
+      # ASAN implicitly runs all UBSAN checks also.
+      sanitizers = "bool,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound"
+      if (!is_mac && !is_win) {
+        sanitizers += ",function"  # Not supported on Mac or Win.
       }
-      if (!is_debug) {
-        sanitizers += ",object-size"  # No-op with somewhat annoying warning at -O0.
+      if (!is_win) {
+        sanitizers += ",vptr"  # Not supported on Win.
+      }
+      if (!is_debug && !is_win) {
+        # No-op with somewhat annoying warning at -O0.
+        # Seems to be broken on Win.
+        sanitizers += ",object-size"
+      }
+      if (sanitize == "ASAN") {
+        sanitizers += ",address"
       }
     } else if (sanitize == "TSAN") {
       sanitizers = "thread"
diff --git a/infra/bots/jobs.json b/infra/bots/jobs.json
index 9d3db0b..176382e 100644
--- a/infra/bots/jobs.json
+++ b/infra/bots/jobs.json
@@ -70,12 +70,14 @@
   "Build-Win-Clang-x86_64-Debug-ANGLE_Goma",
   "Build-Win-Clang-x86_64-Debug-Goma",
   "Build-Win-Clang-x86_64-Debug-GomaNoFallback",
+  "Build-Win-Clang-x86_64-Debug-UBSAN",
   "Build-Win-Clang-x86_64-Debug-Vulkan",
   "Build-Win-Clang-x86_64-Debug-Vulkan_Goma",
   "Build-Win-Clang-x86_64-Release",
   "Build-Win-Clang-x86_64-Release-ANGLE",
   "Build-Win-Clang-x86_64-Release-ANGLE_Goma",
   "Build-Win-Clang-x86_64-Release-Goma",
+  "Build-Win-Clang-x86_64-Release-UBSAN",
   "Build-Win-Clang-x86_64-Release-Vulkan",
   "Build-Win-Clang-x86_64-Release-Vulkan_Goma",
   "Build-Win-MSVC-x86-Debug",
@@ -264,7 +266,9 @@
   "Perf-Win10-MSVC-Golo-GPU-QuadroP400-x86_64-Release-All",
   "Perf-Win10-MSVC-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan",
   "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All",
+  "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN",
   "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All",
+  "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN",
   "Perf-Win2016-MSVC-GCE-CPU-AVX2-x86-Debug-All",
   "Perf-Win2016-MSVC-GCE-CPU-AVX2-x86_64-Debug-All",
   "Perf-Win2016-MSVC-GCE-CPU-AVX2-x86_64-Release-All",
@@ -467,10 +471,12 @@
   "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-FAAA",
   "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-FDAA",
   "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-FSAA",
+  "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN",
   "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All",
   "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-FAAA",
   "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-FDAA",
   "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-FSAA",
+  "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN",
   "Test-Win2016-MSVC-GCE-CPU-AVX2-x86-Debug-All",
   "Test-Win2016-MSVC-GCE-CPU-AVX2-x86-Release-All",
   "Test-Win2016-MSVC-GCE-CPU-AVX2-x86_64-Debug-All",
diff --git a/infra/bots/recipes/perf.py b/infra/bots/recipes/perf.py
index 12945b9..a40bc03 100644
--- a/infra/bots/recipes/perf.py
+++ b/infra/bots/recipes/perf.py
@@ -183,7 +183,7 @@
     match.append('~top25desk_ebay_com.skp_1.1')
   if 'Vulkan' in bot and 'NexusPlayer' in bot:
     match.append('~blendmode_') # skia:6691
-  if 'ASAN' in bot and 'CPU' in bot:
+  if ('ASAN' in bot or 'UBSAN' in bot) and 'CPU' in bot:
     # floor2int_undef benches undefined behavior, so ASAN correctly complains.
     match.append('~^floor2int_undef$')
 
diff --git a/infra/bots/tasks.json b/infra/bots/tasks.json
index 1875039..f1550de 100644
--- a/infra/bots/tasks.json
+++ b/infra/bots/tasks.json
@@ -431,6 +431,12 @@
         "Build-Win-Clang-x86_64-Debug-GomaNoFallback"
       ]
     },
+    "Build-Win-Clang-x86_64-Debug-UBSAN": {
+      "priority": 0.8,
+      "tasks": [
+        "Build-Win-Clang-x86_64-Debug-UBSAN"
+      ]
+    },
     "Build-Win-Clang-x86_64-Debug-Vulkan": {
       "priority": 0.8,
       "tasks": [
@@ -467,6 +473,12 @@
         "Build-Win-Clang-x86_64-Release-Goma"
       ]
     },
+    "Build-Win-Clang-x86_64-Release-UBSAN": {
+      "priority": 0.8,
+      "tasks": [
+        "Build-Win-Clang-x86_64-Release-UBSAN"
+      ]
+    },
     "Build-Win-Clang-x86_64-Release-Vulkan": {
       "priority": 0.8,
       "tasks": [
@@ -1600,12 +1612,24 @@
         "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All"
       ]
     },
+    "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN": {
+      "priority": 0.8,
+      "tasks": [
+        "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN"
+      ]
+    },
     "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All": {
       "priority": 0.8,
       "tasks": [
         "Upload-Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All"
       ]
     },
+    "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN": {
+      "priority": 0.8,
+      "tasks": [
+        "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN"
+      ]
+    },
     "Perf-Win2016-MSVC-GCE-CPU-AVX2-x86-Debug-All": {
       "priority": 0.8,
       "tasks": [
@@ -2820,6 +2844,12 @@
         "Upload-Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-FSAA"
       ]
     },
+    "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN": {
+      "priority": 0.8,
+      "tasks": [
+        "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN"
+      ]
+    },
     "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All": {
       "priority": 0.8,
       "tasks": [
@@ -2844,6 +2874,12 @@
         "Upload-Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-FSAA"
       ]
     },
+    "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN": {
+      "priority": 0.8,
+      "tasks": [
+        "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN"
+      ]
+    },
     "Test-Win2016-MSVC-GCE-CPU-AVX2-x86-Debug-All": {
       "priority": 0.8,
       "tasks": [
@@ -4979,6 +5015,40 @@
       "isolate": "compile_skia.isolate",
       "priority": 0.8
     },
+    "Build-Win-Clang-x86_64-Debug-UBSAN": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/clang_win",
+          "path": "clang_win",
+          "version": "version:2"
+        }
+      ],
+      "dependencies": [
+        "Housekeeper-PerCommit-IsolateWinToolchain"
+      ],
+      "dimensions": [
+        "cpu:x86-64-Haswell_GCE",
+        "gpu:none",
+        "machine_type:n1-highcpu-64",
+        "os:Windows-2016Server-14393",
+        "pool:Skia"
+      ],
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "compile",
+        "repository=<(REPO)",
+        "buildername=Build-Win-Clang-x86_64-Debug-UBSAN",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_repo=<(PATCH_REPO)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "isolate": "compile_skia.isolate",
+      "priority": 0.8
+    },
     "Build-Win-Clang-x86_64-Debug-Vulkan": {
       "cipd_packages": [
         {
@@ -5185,6 +5255,40 @@
       "isolate": "compile_skia.isolate",
       "priority": 0.8
     },
+    "Build-Win-Clang-x86_64-Release-UBSAN": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/clang_win",
+          "path": "clang_win",
+          "version": "version:2"
+        }
+      ],
+      "dependencies": [
+        "Housekeeper-PerCommit-IsolateWinToolchain"
+      ],
+      "dimensions": [
+        "cpu:x86-64-Haswell_GCE",
+        "gpu:none",
+        "machine_type:n1-highcpu-64",
+        "os:Windows-2016Server-14393",
+        "pool:Skia"
+      ],
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "compile",
+        "repository=<(REPO)",
+        "buildername=Build-Win-Clang-x86_64-Release-UBSAN",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_repo=<(PATCH_REPO)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "isolate": "compile_skia.isolate",
+      "priority": 0.8
+    },
     "Build-Win-Clang-x86_64-Release-Vulkan": {
       "cipd_packages": [
         {
@@ -12939,6 +13043,54 @@
       "max_attempts": 1,
       "priority": 0.8
     },
+    "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/skimage",
+          "path": "skimage",
+          "version": "version:34"
+        },
+        {
+          "name": "skia/bots/skp",
+          "path": "skp",
+          "version": "version:108"
+        },
+        {
+          "name": "skia/bots/svg",
+          "path": "svg",
+          "version": "version:9"
+        }
+      ],
+      "dependencies": [
+        "Build-Win-Clang-x86_64-Debug-UBSAN",
+        "Housekeeper-PerCommit-BundleRecipes"
+      ],
+      "dimensions": [
+        "cpu:x86-64-Haswell_GCE",
+        "machine_type:n1-standard-16",
+        "os:Windows-2016Server-14393",
+        "pool:Skia"
+      ],
+      "execution_timeout_ns": 14400000000000,
+      "expiration_ns": 72000000000000,
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "perf",
+        "repository=<(REPO)",
+        "buildername=Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_repo=<(PATCH_REPO)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "io_timeout_ns": 2400000000000,
+      "isolate": "perf_skia_bundled_win.isolate",
+      "max_attempts": 1,
+      "priority": 0.8
+    },
     "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All": {
       "cipd_packages": [
         {
@@ -12987,6 +13139,54 @@
       "max_attempts": 1,
       "priority": 0.8
     },
+    "Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/skimage",
+          "path": "skimage",
+          "version": "version:34"
+        },
+        {
+          "name": "skia/bots/skp",
+          "path": "skp",
+          "version": "version:108"
+        },
+        {
+          "name": "skia/bots/svg",
+          "path": "svg",
+          "version": "version:9"
+        }
+      ],
+      "dependencies": [
+        "Build-Win-Clang-x86_64-Release-UBSAN",
+        "Housekeeper-PerCommit-BundleRecipes"
+      ],
+      "dimensions": [
+        "cpu:x86-64-Haswell_GCE",
+        "machine_type:n1-standard-16",
+        "os:Windows-2016Server-14393",
+        "pool:Skia"
+      ],
+      "execution_timeout_ns": 14400000000000,
+      "expiration_ns": 72000000000000,
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "perf",
+        "repository=<(REPO)",
+        "buildername=Perf-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_repo=<(PATCH_REPO)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "io_timeout_ns": 2400000000000,
+      "isolate": "perf_skia_bundled_win.isolate",
+      "max_attempts": 1,
+      "priority": 0.8
+    },
     "Perf-Win2016-MSVC-GCE-CPU-AVX2-x86-Debug-All": {
       "cipd_packages": [
         {
@@ -22384,6 +22584,55 @@
       "max_attempts": 1,
       "priority": 0.8
     },
+    "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/skimage",
+          "path": "skimage",
+          "version": "version:34"
+        },
+        {
+          "name": "skia/bots/skp",
+          "path": "skp",
+          "version": "version:108"
+        },
+        {
+          "name": "skia/bots/svg",
+          "path": "svg",
+          "version": "version:9"
+        }
+      ],
+      "dependencies": [
+        "Build-Win-Clang-x86_64-Debug-UBSAN",
+        "Housekeeper-PerCommit-BundleRecipes"
+      ],
+      "dimensions": [
+        "cpu:x86-64-Haswell_GCE",
+        "machine_type:n1-standard-16",
+        "os:Windows-2016Server-14393",
+        "pool:Skia"
+      ],
+      "execution_timeout_ns": 14400000000000,
+      "expiration_ns": 72000000000000,
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "test",
+        "repository=<(REPO)",
+        "buildbucket_build_id=<(BUILDBUCKET_BUILD_ID)",
+        "buildername=Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Debug-All-UBSAN",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_repo=<(PATCH_REPO)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "io_timeout_ns": 2400000000000,
+      "isolate": "test_skia_bundled_win.isolate",
+      "max_attempts": 1,
+      "priority": 0.8
+    },
     "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All": {
       "cipd_packages": [
         {
@@ -22580,6 +22829,55 @@
       "max_attempts": 1,
       "priority": 0.8
     },
+    "Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/skimage",
+          "path": "skimage",
+          "version": "version:34"
+        },
+        {
+          "name": "skia/bots/skp",
+          "path": "skp",
+          "version": "version:108"
+        },
+        {
+          "name": "skia/bots/svg",
+          "path": "svg",
+          "version": "version:9"
+        }
+      ],
+      "dependencies": [
+        "Build-Win-Clang-x86_64-Release-UBSAN",
+        "Housekeeper-PerCommit-BundleRecipes"
+      ],
+      "dimensions": [
+        "cpu:x86-64-Haswell_GCE",
+        "machine_type:n1-standard-16",
+        "os:Windows-2016Server-14393",
+        "pool:Skia"
+      ],
+      "execution_timeout_ns": 14400000000000,
+      "expiration_ns": 72000000000000,
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "test",
+        "repository=<(REPO)",
+        "buildbucket_build_id=<(BUILDBUCKET_BUILD_ID)",
+        "buildername=Test-Win2016-Clang-GCE-CPU-AVX2-x86_64-Release-All-UBSAN",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_repo=<(PATCH_REPO)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "io_timeout_ns": 2400000000000,
+      "isolate": "test_skia_bundled_win.isolate",
+      "max_attempts": 1,
+      "priority": 0.8
+    },
     "Test-Win2016-MSVC-GCE-CPU-AVX2-x86-Debug-All": {
       "cipd_packages": [
         {