Fix a crash with the WebGL conformance test suite.
Undefined behavior caused by an overflowed enum was causing
the translator symbol table stack to not get popped correctly
when the compiler completed, causing dangling symbols who's storage
was reclaimed and reused when the allocation pool was popped.
The error occurred in the "shader-with-reserved-words" test, which
passes when the compiler fails due to the use of reserved words as
identifiers. As such, this test would pass even if the GPU process
crashes but further tests in the test suite would fail.
BUG=angle::785, 786
Change-Id: I365cb55f962f8dfe409f40532effeb10b8189432
Reviewed-on: https://chromium-review.googlesource.com/223093
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Nicolas Capens <capn@chromium.org>
Tested-by: Gus Fernandez <gusfernandez@chromium.org>
diff --git a/src/compiler/translator/SymbolTable.h b/src/compiler/translator/SymbolTable.h
index 6b0e0c0..c32e0cc 100644
--- a/src/compiler/translator/SymbolTable.h
+++ b/src/compiler/translator/SymbolTable.h
@@ -299,14 +299,15 @@
tLevel level;
};
-enum ESymbolLevel
-{
- COMMON_BUILTINS = 0,
- ESSL1_BUILTINS = 1,
- ESSL3_BUILTINS = 2,
- LAST_BUILTIN_LEVEL = ESSL3_BUILTINS,
- GLOBAL_LEVEL = 3
-};
+// Define ESymbolLevel as int rather than an enum since level can go
+// above GLOBAL_LEVEL and cause atBuiltInLevel() to fail if the
+// compiler optimizes the >= of the last element to ==.
+typedef int ESymbolLevel;
+const int COMMON_BUILTINS = 0;
+const int ESSL1_BUILTINS = 1;
+const int ESSL3_BUILTINS = 2;
+const int LAST_BUILTIN_LEVEL = ESSL3_BUILTINS;
+const int GLOBAL_LEVEL = 3;
class TSymbolTable
{