Fixed DSLParser assertion error uncovered by fuzzer
Bug: oss-fuzz:38108 Change-Id: I0e055d837923f00b982bc395dbf29b6ff59a3b21 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448896 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
64be3c5867
commit
c973d26854
@ -104,6 +104,7 @@ sksl_error_tests = [
|
||||
"/sksl/errors/Ossfuzz37620.sksl",
|
||||
"/sksl/errors/Ossfuzz38106.sksl",
|
||||
"/sksl/errors/Ossfuzz38107.sksl",
|
||||
"/sksl/errors/Ossfuzz38108.sksl",
|
||||
"/sksl/errors/Ossfuzz38140.sksl",
|
||||
"/sksl/errors/Ossfuzz38560.sksl",
|
||||
"/sksl/errors/Ossfuzz38865.sksl",
|
||||
|
@ -57,7 +57,7 @@ bool IsType(skstd::string_view name);
|
||||
/**
|
||||
* Adds a variable to the current symbol table.
|
||||
*/
|
||||
void AddToSymbolTable(DSLVarBase& var);
|
||||
void AddToSymbolTable(DSLVarBase& var, PositionInfo pos = PositionInfo::Capture());
|
||||
|
||||
} // namespace dsl
|
||||
|
||||
|
@ -2,4 +2,6 @@ int x;
|
||||
int x;
|
||||
|
||||
int main;
|
||||
void main() {}
|
||||
void main() {
|
||||
int y,y;
|
||||
}
|
||||
|
1
resources/sksl/errors/Ossfuzz38108.sksl
Normal file
1
resources/sksl/errors/Ossfuzz38108.sksl
Normal file
@ -0,0 +1 @@
|
||||
int a,a;
|
@ -884,6 +884,7 @@ bool Compiler::toSPIRV(Program& program, OutputStream& out) {
|
||||
errors.append(disassembly);
|
||||
}
|
||||
this->errorReporter().error(-1, errors);
|
||||
this->errorReporter().reportPendingErrors(PositionInfo());
|
||||
#else
|
||||
SkDEBUGFAILF("%s", errors.c_str());
|
||||
#endif
|
||||
@ -957,7 +958,6 @@ void Compiler::handleError(skstd::string_view msg, PositionInfo pos) {
|
||||
}
|
||||
|
||||
String Compiler::errorText(bool showCount) {
|
||||
this->errorReporter().reportPendingErrors(PositionInfo());
|
||||
if (showCount) {
|
||||
this->writeErrorCount();
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ void DSLParser::globalVarDeclarationEnd(PositionInfo pos, const dsl::DSLModifier
|
||||
}
|
||||
DSLGlobalVar next(mods, type, this->text(identifierName), std::move(anotherInitializer));
|
||||
Declare(next);
|
||||
AddToSymbolTable(next);
|
||||
AddToSymbolTable(next, this->position(identifierName));
|
||||
}
|
||||
this->expect(Token::Kind::TK_SEMICOLON, "';'");
|
||||
}
|
||||
@ -486,7 +486,7 @@ DSLStatement DSLParser::localVarDeclarationEnd(PositionInfo pos, const dsl::DSLM
|
||||
}
|
||||
DSLVar next(mods, type, this->text(identifierName), std::move(anotherInitializer));
|
||||
DSLWriter::AddVarDeclaration(result, next);
|
||||
AddToSymbolTable(next);
|
||||
AddToSymbolTable(next, this->position(identifierName));
|
||||
}
|
||||
this->expect(Token::Kind::TK_SEMICOLON, "';'");
|
||||
return result;
|
||||
|
@ -35,11 +35,12 @@ bool IsType(skstd::string_view name) {
|
||||
return s && s->is<Type>();
|
||||
}
|
||||
|
||||
void AddToSymbolTable(DSLVarBase& var) {
|
||||
void AddToSymbolTable(DSLVarBase& var, PositionInfo pos) {
|
||||
const SkSL::Variable* skslVar = DSLWriter::Var(var);
|
||||
if (skslVar) {
|
||||
CurrentSymbolTable()->addWithoutOwnership(skslVar);
|
||||
}
|
||||
DSLWriter::ReportErrors(pos);
|
||||
}
|
||||
|
||||
const String* Retain(String string) {
|
||||
|
@ -2,4 +2,5 @@
|
||||
|
||||
error: 2: symbol 'x' was already defined
|
||||
error: 5: symbol 'main' was already defined
|
||||
2 errors
|
||||
error: 6: symbol 'y' was already defined
|
||||
3 errors
|
||||
|
4
tests/sksl/errors/Ossfuzz38108.glsl
Normal file
4
tests/sksl/errors/Ossfuzz38108.glsl
Normal file
@ -0,0 +1,4 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 1: symbol 'a' was already defined
|
||||
1 error
|
Loading…
Reference in New Issue
Block a user