Skip to content

Commit 29aa33d

Browse files
committed
fuzz: disable Zend's arena allocator under go-118-fuzz-build
Zend's own arena allocator reuses freed memory in ways that hide bugs from ASan/MSan; disabling it (USE_ZEND_ALLOC=0) is already required for the sanitizer CI jobs (.github/workflows/sanitizers.yaml), but that env var never reaches a libFuzzer binary built by OSS-Fuzz: build.sh runs in a throwaway build container, and ClusterFuzz later execs the compiled fuzzer as a fresh process on a different bot with no inherited env. The libFuzzer .options file can't fill the gap either, since ClusterFuzz whitelists its [env] section down to two unrelated variables. Setting it from an init() gated on the "gofuzz" build tag reaches the process before PHP starts, without touching any non-fuzzing build.
1 parent 6845134 commit 29aa33d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

zendalloc_gofuzz.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build gofuzz
2+
3+
package frankenphp
4+
5+
import "os"
6+
7+
func init() {
8+
// Zend's own arena allocator hides bugs from the sanitizers OSS-Fuzz builds with.
9+
os.Setenv("USE_ZEND_ALLOC", "0")
10+
}

0 commit comments

Comments
 (0)