Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Perron <stevenperron@google.com>2022-07-06 03:12:58 +0300
committerGitHub <noreply@github.com>2022-07-06 03:12:58 +0300
commit5f4284aa7823877744e7b8144f52964e012252f0 (patch)
treee86690d663755905a48c808d0f69327642571c51
parent92fe420c8a8b8527eb99b9096ad0c29efc696de8 (diff)
Add limit for scalar replacment when fuzzing (#4843)
The fuzzer cretes code with very large array, and scalar replacement times out. Adding a limit on the size of the composites that will be split when fuzzing. Fixes https://crbug.com/oss-fuzz/48630
-rw-r--r--source/opt/scalar_replacement_pass.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/opt/scalar_replacement_pass.h b/source/opt/scalar_replacement_pass.h
index 3d1377bf7..6a66dfb80 100644
--- a/source/opt/scalar_replacement_pass.h
+++ b/source/opt/scalar_replacement_pass.h
@@ -42,6 +42,16 @@ class ScalarReplacementPass : public MemPass {
name_, sizeof(name_), "scalar-replacement=%u", max_num_elements_);
assert(size_t(num_to_write) < sizeof(name_));
(void)num_to_write; // Mark as unused
+
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+ // ClusterFuzz/OSS-Fuzz is likely to yield examples with very large arrays.
+ // This can cause timeouts and memouts during fuzzing that
+ // are not classed as bugs. To avoid this noise, we set the
+ // max_num_elements_ to a smaller value for fuzzing.
+ max_num_elements_ =
+ (max_num_elements_ > 0 && max_num_elements_ < 100 ? max_num_elements_
+ : 100);
+#endif
}
const char* name() const override { return name_; }