Add program-too-large test using for loops without blocks.

The fuzzer has discovered a bug in our program size-checking logic; for
loops that immediately contain another for loop (with no block) were not
counting the inner loop's iterations. This allowed it to exceed our
maximum program-size threshold (and time out during SkVM compilation).

This test demonstrates the issue. A followup will fix it.

Change-Id: I3b7d4c8a4f0ed04cf0aba3f1a32fdad7d6d784e7
Bug: oss-fuzz:37837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449096
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
John Stiles 2021-09-15 09:42:36 -04:00
parent 8a05251321
commit 857c7f9dc5
6 changed files with 45 additions and 0 deletions

View File

@ -540,6 +540,7 @@ sksl_rte_tests = [
"/sksl/runtime/ConversionConstructors.rts",
"/sksl/runtime/GLSLTypeNames.rts",
"/sksl/runtime/GlobalVariables.rts",
"/sksl/runtime/LargeProgram_BlocklessLoops.rts",
"/sksl/runtime/LargeProgram_FlatLoop.rts",
"/sksl/runtime/LargeProgram_Functions.rts",
"/sksl/runtime/LargeProgram_NestedLoops.rts",
@ -577,6 +578,7 @@ sksl_rte_error_tests = [
"/sksl/runtime_errors/LoopStructureErrors.rts",
"/sksl/runtime_errors/Ossfuzz36655.rts",
"/sksl/runtime_errors/Ossfuzz38131.rts",
"/sksl/runtime_errors/ProgramTooLarge_BlocklessLoops.rts",
"/sksl/runtime_errors/ProgramTooLarge_FlatLoop.rts",
"/sksl/runtime_errors/ProgramTooLarge_Functions.rts",
"/sksl/runtime_errors/ProgramTooLarge_NestedLoops.rts",

View File

@ -0,0 +1,11 @@
half4 main(float2 xy) {
int i;
for (int a=0; a<10; ++a) // 10
for (int b=0; b<10; ++b) // 100
for (int c=0; c<10; ++c) // 1000
for (int d=0; d<10; ++d) // 10000
++i;
return half4(0);
}

View File

@ -0,0 +1,12 @@
half4 main(float2 xy) {
int i;
for (int a=0; a<10; ++a) // 10
for (int b=0; b<10; ++b) // 100
for (int c=0; c<10; ++c) // 1000
for (int d=0; d<10; ++d) // 10000
for (int e=0; e<10; ++e) // 100000
++i;
return half4(0);
}

View File

@ -0,0 +1,7 @@
1 registers, 5 instructions:
0 r0 = splat 0 (0)
loop:
1 store32 ptr1 r0
2 store32 ptr2 r0
3 store32 ptr3 r0
4 store32 ptr4 r0

View File

@ -0,0 +1,6 @@
half4 main(float2 xy)
{
int i;
for (int a = 0;a < 10; ++a) for (int b = 0;b < 10; ++b) for (int c = 0;c < 10; ++c) for (int d = 0;d < 10; ++d) ++i;
return half4(half4(0.0));
}

View File

@ -0,0 +1,7 @@
1 registers, 5 instructions:
0 r0 = splat 0 (0)
loop:
1 store32 ptr1 r0
2 store32 ptr2 r0
3 store32 ptr3 r0
4 store32 ptr4 r0