fuzz hang fix and pathops client debugging

The ASAN fuzzer on chrome caught a hanging state.

To capture the data, allow the pathops client debugging
to run in a release build.

TBR=reed@google.com
BUG=665295

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4834

Change-Id: I6b2c2baabd63994f63aa730d2ee7828986b5ab89
Reviewed-on: https://skia-review.googlesource.com/4834
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
diff --git a/src/pathops/SkOpSegment.cpp b/src/pathops/SkOpSegment.cpp
index f3f8747..a1818d3 100644
--- a/src/pathops/SkOpSegment.cpp
+++ b/src/pathops/SkOpSegment.cpp
@@ -837,12 +837,19 @@
     markDone(minSpan);
     SkOpSpanBase* last = nullptr;
     SkOpSegment* other = this;
+    SkOpSpan* priorDone = nullptr;
+    SkOpSpan* lastDone = nullptr;
     while ((other = other->nextChase(&start, &step, &minSpan, &last))) {
         if (other->done()) {
             SkASSERT(!last);
             break;
         }
+        if (lastDone == minSpan || priorDone == minSpan) {
+            return nullptr;
+        }
         other->markDone(minSpan);
+        priorDone = lastDone;
+        lastDone = minSpan;
     }
     return last;
 }
diff --git a/src/pathops/SkPathOpsDebug.cpp b/src/pathops/SkPathOpsDebug.cpp
index 58b33c0..0906c45 100644
--- a/src/pathops/SkPathOpsDebug.cpp
+++ b/src/pathops/SkPathOpsDebug.cpp
@@ -13,7 +13,7 @@
 #include "SkPathOpsDebug.h"
 #include "SkString.h"
 
-#ifdef SK_DEBUG
+#if DEBUG_DUMP_VERIFY
 bool SkPathOpsDebug::gDumpOp;  // set to true to write op to file before a crash
 bool SkPathOpsDebug::gVerifyOp;  // set to true to compare result against regions
 #endif
@@ -2906,7 +2906,7 @@
     showPathContours(iter, name);
 }
 
-#ifdef SK_DEBUG
+#if DEBUG_DUMP_VERIFY
 #include "SkData.h"
 #include "SkStream.h"
 
diff --git a/src/pathops/SkPathOpsDebug.h b/src/pathops/SkPathOpsDebug.h
index 0258d58..aba02b1 100644
--- a/src/pathops/SkPathOpsDebug.h
+++ b/src/pathops/SkPathOpsDebug.h
@@ -58,6 +58,7 @@
 #define DEBUG_CUBIC_BINARY_SEARCH 0
 #define DEBUG_CUBIC_SPLIT 0
 #define DEBUG_DUMP_SEGMENTS 0
+#define DEBUG_DUMP_VERIFY 0
 #define DEBUG_FLOW 0
 #define DEBUG_LIMIT_WIND_SUM 0
 #define DEBUG_MARK_DONE 0
@@ -87,6 +88,7 @@
 #define DEBUG_COINCIDENCE_VERBOSE 01
 #define DEBUG_CUBIC_BINARY_SEARCH 0
 #define DEBUG_CUBIC_SPLIT 1
+#define DEBUG_DUMP_VERIFY 0
 #define DEBUG_DUMP_SEGMENTS 1
 #define DEBUG_FLOW 1
 #define DEBUG_LIMIT_WIND_SUM 15
@@ -375,7 +377,7 @@
     static bool gRunFail;
     static bool gVeryVerbose;
 
-#ifdef SK_DEBUG
+#if DEBUG_DUMP_VERIFY
     static bool gDumpOp;
     static bool gVerifyOp;
 
diff --git a/src/pathops/SkPathOpsOp.cpp b/src/pathops/SkPathOpsOp.cpp
index f423ba9..f6b08ea 100644
--- a/src/pathops/SkPathOpsOp.cpp
+++ b/src/pathops/SkPathOpsOp.cpp
@@ -223,7 +223,10 @@
     SkOpGlobalState globalState(contourList, &allocator
             SkDEBUGPARAMS(skipAssert) SkDEBUGPARAMS(testName));
     SkOpCoincidence coincidence(&globalState);
-#ifdef SK_DEBUG
+#if DEBUG_DUMP_VERIFY
+#ifndef SK_DEBUG
+    const char* testName = "release";
+#endif
     if (SkPathOpsDebug::gDumpOp) {
         SkPathOpsDebug::DumpOp(one, two, op, testName);
     }
@@ -316,7 +319,7 @@
 }
 
 bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) {
-#ifdef SK_DEBUG
+#if DEBUG_DUMP_VERIFY
     if (SkPathOpsDebug::gVerifyOp) {
         if (!OpDebug(one, two, op, result  SkDEBUGPARAMS(false) SkDEBUGPARAMS(nullptr))) {
             SkPathOpsDebug::ReportOpFail(one, two, op);
diff --git a/src/pathops/SkPathOpsSimplify.cpp b/src/pathops/SkPathOpsSimplify.cpp
index d587c3b..8cd770d 100644
--- a/src/pathops/SkPathOpsSimplify.cpp
+++ b/src/pathops/SkPathOpsSimplify.cpp
@@ -158,7 +158,10 @@
     SkOpGlobalState globalState(contourList, &allocator
             SkDEBUGPARAMS(skipAssert) SkDEBUGPARAMS(testName));
     SkOpCoincidence coincidence(&globalState);
-#ifdef SK_DEBUG
+#if DEBUG_DUMP_VERIFY
+#ifndef SK_DEBUG
+    const char* testName = "release";
+#endif
     if (SkPathOpsDebug::gDumpOp) {
         SkPathOpsDebug::DumpSimplify(path, testName);
     }
@@ -223,7 +226,7 @@
 }
 
 bool Simplify(const SkPath& path, SkPath* result) {
-#ifdef SK_DEBUG
+#if DEBUG_DUMP_VERIFY
     if (SkPathOpsDebug::gVerifyOp) {
         if (!SimplifyDebug(path, result  SkDEBUGPARAMS(false) SkDEBUGPARAMS(nullptr))) {
             SkPathOpsDebug::ReportSimplifyFail(path);