Only perform unrolled-size check on valid code.
This analysis pass assumes we have a program with a valid structure--all
loops must be ES2-compliant, and all function-calls must reference real
functions that exist. If we detected an error during compilation, our
program might not meet these criteria.
Change-Id: I4c7aefb3221438643614f1e0cbc2bad40b94b161
Bug: skia:12396
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444982
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 3c90c4e..5ab501f 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -811,16 +811,15 @@
// FunctionReference or TypeReference expressions. Report these as errors.
Analysis::VerifyStaticTestsAndExpressions(program);
- // If we're in ES2 mode (runtime effects), do a pass to enforce Appendix A, Section 5 of the
- // GLSL ES 1.00 spec -- Indexing. Don't bother if we've already found errors - this logic
- // assumes that all loops meet the criteria of Section 4, and if they don't, could crash.
+ // Verify that the program conforms to ES2 limitations.
if (fContext->fConfig->strictES2Mode() && this->errorCount() == 0) {
+ // Enforce Appendix A, Section 5 of the GLSL ES 1.00 spec -- Indexing. This logic assumes
+ // that all loops meet the criteria of Section 4, and if they don't, could crash.
for (const auto& pe : program.ownedElements()) {
Analysis::ValidateIndexingForES2(*pe, this->errorReporter());
}
- }
-
- if (fContext->fConfig->strictES2Mode()) {
+ // Verify that the program size is reasonable after unrolling and inlining. This also
+ // issues errors for static recursion and overly-deep function-call chains.
Analysis::CheckProgramUnrolledSize(program);
}
diff --git a/tests/sksl/runtime_errors/Ossfuzz36655.skvm b/tests/sksl/runtime_errors/Ossfuzz36655.skvm
index fba9a1a..6fc6e30 100644
--- a/tests/sksl/runtime_errors/Ossfuzz36655.skvm
+++ b/tests/sksl/runtime_errors/Ossfuzz36655.skvm
@@ -5,7 +5,4 @@
error: 31: static if has non-static test
error: 38: static if has non-static test
error: 44: static if has non-static test
-error: 13: potential recursion (function call cycle) not allowed:
- void X()
- void X()
-6 errors
+5 errors