skia2/resources/sksl/runtime_errors/ProgramTooLarge_Functions.rts
John Stiles 61e5e202a5 Enforce an upper bound on Runtime Effect program size.
The fuzzer is currently learning to make unboundedly-large programs by
nesting medium-size loops repeatedly. SkVM doesn't have a mechanism to
limit the ensuing explosion of code and ends up making unreasonably deep
stacks and/or unreasonably large programs.

SkSL now enforces an upper bound of approximately 100,000 IR nodes on a
fully-flattened, fully-inlined strict-ES2 program. The limit is picked
out of thin air, but this should be enough to prevent SkVM from going
haywire while still being large enough to handle any reasonable program.
We can definitely tune this value if we find that it is too large
(admitting dangerous code) or too small (rejecting good code).

Change-Id: I11735636175721fbc79460b4e194d8e4b42dc47d
Bug: skia:12396, oss-fuzz:37827, oss-fuzz:37837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444358
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-02 14:44:34 +00:00

12 lines
533 B
Plaintext

void e(inout int i) { ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; } // 100000
void d(inout int i) { e(i); e(i); e(i); e(i); e(i); e(i); e(i); e(i); e(i); e(i); } // 10000
void c(inout int i) { d(i); d(i); d(i); d(i); d(i); d(i); d(i); d(i); d(i); d(i); } // 1000
void b(inout int i) { c(i); c(i); c(i); c(i); c(i); c(i); c(i); c(i); c(i); c(i); } // 100
void a(inout int i) { b(i); b(i); b(i); b(i); b(i); b(i); b(i); b(i); b(i); b(i); } // 10
half4 main(float2 xy) {
int i = 0;
a(i);
return half4(0);
}