fuzz: allows compiler=stackoverflow,intp=unreachable (#1779)

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
Takeshi Yoneda
2023-10-13 10:37:11 +09:00
committed by GitHub
parent 4071f828ff
commit 44f23e2643
3 changed files with 11 additions and 3 deletions

View File

@@ -60,7 +60,11 @@ const (
func CheckStackGuardPage(s []byte) {
for i := 0; i < StackGuardCheckGuardPageSize; i++ {
if s[i] != 0 {
panic(fmt.Sprintf("BUG: stack guard page is corrupted: %s", hex.EncodeToString(s[:StackGuardCheckGuardPageSize])))
panic(
fmt.Sprintf("BUG: stack guard page is corrupted:\n\tguard_page=%s\n\tstack=%s",
hex.EncodeToString(s[:StackGuardCheckGuardPageSize]),
hex.EncodeToString(s[StackGuardCheckGuardPageSize:]),
))
}
}
}

View File

@@ -1,7 +1,5 @@
//! This module provides the functions implemented by wazero via CGo.
use wasm_smith::SwarmConfig;
extern "C" {
// require_no_diff is implemented in Go, and accepts the pointer to the binary and its size.
#[allow(dead_code)]

View File

@@ -314,6 +314,12 @@ func ensureInvocationError(compilerErr, interpErr error) error {
interpErrMsg = interpErrMsg[:strings.Index(interpErrMsg, "\n")]
}
if strings.Contains(compilerErrMsg, "stack overflow") && strings.Contains(interpErrMsg, "unreachable") {
// Compiler is more likely to reach stack overflow than interpreter, so we allow this case. This case is most likely
// that interpreter reached the unreachable out of "fuel".
return nil
}
if compilerErrMsg != interpErrMsg {
return fmt.Errorf("error mismatch:\n\tinterpreter: %v\n\tcompiler: %v", interpErr, compilerErr)
}