Fix OSS-Fuzz fuzzer build: memcheck/expr_exit defaults and VM cleanup - #104
Open
xingyaner wants to merge 1 commit into
Open
Fix OSS-Fuzz fuzzer build: memcheck/expr_exit defaults and VM cleanup#104xingyaner wants to merge 1 commit into
xingyaner wants to merge 1 commit into
Conversation
gavinhoward
requested changes
Aug 2, 2026
gavinhoward
left a comment
Owner
There was a problem hiding this comment.
I'm so glad you found the leak problem!
Only one note: on the memcheck check in configure.sh, you need to remove the line with usage because usage prints an error message and exits with an error. So memcheck=1 does nothing, and the rest of the script will not run.
Other than that, because you did the legwork, it looks great, and I'll approve it.
Author
|
Thanks for catching this. I've updated the code accordingly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The OSS-Fuzz build invokes ./configure -Z, which previously aborted with Can only enable OSSFUZZ when MEMCHECK is enabled. This change makes -Z automatically enable memcheck instead of erroring, because memcheck mode is what makes bc_vm_shutdown() run the full heap cleanup. Without memcheck, the built fuzzers crashed at runtime with Assertion '!BC_ENABLE_OSSFUZZ || BC_EXPR_EXIT == 0' failed (src/vm.c:1481), since the default bc.expr_exit/dc.expr_exit were 1; the fuzz/OSS-Fuzz modes now set both defaults to 0 to satisfy that assertion. LeakSanitizer additionally reported a Direct leak of 6400 byte(s) originating from bc_program_exec, because LLVMFuzzerTestOneInput freed only bc_fuzzer_data and never released the VM state allocated by bc_main()/dc_main(). The fuzzers now call bc_vm_atexit(s) before returning, which under memcheck frees all VM heap state and eliminates the leaks. With these changes, build_fuzzers and check_build pass for both the AFL and libFuzzer engines (address sanitizer, x86_64), and a normal non-fuzz build shows no regression.