diff --git a/.github/workflows/run_fuzzer.yml b/.github/workflows/run_fuzzer.yml index 37b17b950..95ec9c459 100644 --- a/.github/workflows/run_fuzzer.yml +++ b/.github/workflows/run_fuzzer.yml @@ -63,15 +63,9 @@ jobs: cxxstd: 17 targets: libs/json/fuzzing//run - name: Pack the corpus - working-directory: boost-root/libs/json/fuzzing/ + working-directory: boost-root/libs/json/fuzzing/cmin run: | - tar cf - cmin > corpus.tar.tmp && mv corpus.tar.tmp "${GITHUB_WORKSPACE}"/head/fuzzing - - name: Save the corpus as a github artifact - uses: actions/upload-artifact@v4 - if: success() - with: - name: corpus - path: head/fuzzing/corpus.tar + tar cf - * > "$GITHUB_WORKSPACE"/head/fuzzing/corpus.tar - name: Archive any crashes as an artifact uses: actions/upload-artifact@v4 if: always() diff --git a/fuzzing/Jamfile b/fuzzing/Jamfile index 0eef94aca..c5c2f3c58 100644 --- a/fuzzing/Jamfile +++ b/fuzzing/Jamfile @@ -39,32 +39,31 @@ import testing ; ] ; local corpus.tar = [ glob-ex . : corpus.tar ] ; +local test-corpus ; if $(corpus.tar) { # if an old corpus exists, use it - # get it with curl -O --location -J https://bintray.com/pauldreik/boost.json/download_file?file_path=corpus%2Fcorpus.tar make old-corpus : $(corpus.tar) : @untar-corpus : oldcorpus ; + explicit old-corpus ; } else { - alias old-corpus ; + test-corpus = [ glob-tree-ex ../test : *.json ] ; } -explicit old-corpus ; - - -local initial-corpus = [ glob-tree-ex ../test : *.json ] ; +local old-runs = [ SORT [ glob-tree-ex old_crashes : * ] ] ; +make old_crashes : : @mkdir : . ; +explicit old_crashes ; local variants = basic_parser parse parser direct_parse ; for local variant in basic_parser parse parser direct_parse { local $(variant)-runs ; local fuzzer = fuzzer_$(variant) ; - lib $(fuzzer) : fuzz_$(variant).cpp /boost/json//boost_json ; exe $(fuzzer) : fuzz_$(variant).cpp /boost/json//json_sources : requirements @@ -73,44 +72,44 @@ for local variant in basic_parser parse parser direct_parse ; # make sure the old crashes pass without problems - local old-runs = [ glob-tree-ex old_crashes/$(variant) : * ] ; if $(old-runs) { run $(fuzzer) : target-name $(variant)-run-crashes - : input-files [ SORT $(old-runs) ] + : input-files $(old-runs) ; + explicit $(variant)-run-crashes ; $(variant)-runs += $(variant)-run-crashes ; } - make oldcorpus/$(variant) - : old-corpus - : common.MkDir - : . - ; - explicit oldcorpus/$(variant) ; - - # make an initial corpus from the test data already in the repo - local seed-corpus ; - for file in $(initial-corpus) + local old-corpus-deps ; + if $(corpus.tar) { - local copied = $(variant)/$(file:D=) ; - make $(copied) : $(file) : common.copy : seedcorpus ; - explicit $(copied) ; - seed-corpus += $(copied) ; + old-corpus-deps = old-corpus ; } - make seedcorpus/$(variant) - : $(seed-corpus) - : common.MkDir + else + { + # make an initial corpus from the test data already in the repo + for file in $(test-corpus) + { + local copied = $(variant)/$(file:D=) ; + make $(copied) : $(file) : common.copy : oldcorpus ; + explicit $(copied) ; + old-corpus-deps += $(copied) ; + } + } + make oldcorpus/$(variant) + : $(old-corpus-deps) + : @mkdir : . ; - explicit seedcorpus/$(variant) ; + explicit oldcorpus/$(variant) ; # run the fuzzer for a short while make out/$(variant) : $(fuzzer) oldcorpus/$(variant) - seedcorpus/$(variant) + old_crashes : @run-fuzzer : . $(.MAXTIME) @@ -122,8 +121,9 @@ for local variant in basic_parser parse parser direct_parse # minimize the corpus make cmin/$(variant) : $(fuzzer) - oldcorpus/$(variant) out/$(variant) + oldcorpus/$(variant) + old_crashes : @run-fuzzer : . -merge=1 @@ -139,6 +139,13 @@ alias run : $(variants)-run ; explicit run $(variants)-run ; +rule mkdir ( target : source * : props * ) +{ + local dir = [ path.make [ on $(target) return $(LOCATE) ] ] ; + dir = [ path.join $(dir) $(target:G=) ] ; + common.MkDir $(dir) ; +} + rule fuzzer-props ( props * ) { local toolset = [ property.select toolset : $(props) ] ; @@ -169,16 +176,36 @@ rule run-fuzzer ( target : sources * : props * ) local flags = [ property.select flags : $(props) ] ; FLAGS on $(target) = $(flags:G=) ; + LOG on $(target) = [ path.native [ path.join $(target) _log ] ] ; + local dir = [ path.make [ on $(target) return $(LOCATE) ] ] ; dir = $(dir)/$(target:G=) ; common.MkDir $(dir) ; DEPENDS $(target) : $(dir) ; + + LOG on $(target) = [ path.native [ path.join $(dir) _log ] ] ; } +.SET_STATUS = [ modules.peek testing : .SET_STATUS ] ; +.STATUS = [ modules.peek testing : .STATUS ] ; +.RUN_OUTPUT_NL = [ modules.peek testing : .RUN_OUTPUT_NL ] ; +.STATUS_NOT_0 = [ modules.peek testing : .STATUS_NOT_0 ] ; +.CATENATE = [ modules.peek testing : .CATENATE ] ; +.ENDIF = [ modules.peek testing : .ENDIF ] ; +.NULL_OUT = [ modules.peek common : NULL_OUT ] ; +.RM = [ common.rm-command ] ; actions run-fuzzer { $(.UBSAN_OPTIONS) - $(>[1]) $(<) $(>[2]) $(>[3]) $(FLAGS) + $(>[1]) $(<) $(>[2-]) $(FLAGS) > "$(LOG)" 2>&1 + $(.SET_STATUS) + if $(.STATUS_NOT_0) + echo ====== BEGIN OUTPUT ====== + $(.CATENATE) "$(LOG)" + echo ====== END OUTPUT ====== + $(RM) $(LOG) $(.NULL_OUT) + exit 1 + $(.ENDIF) } .TOUCH_FILE = [ common.file-touch-command ] ; diff --git a/fuzzing/old_crashes/basic_parser/20200903.json b/fuzzing/old_crashes/20200903.json similarity index 100% rename from fuzzing/old_crashes/basic_parser/20200903.json rename to fuzzing/old_crashes/20200903.json diff --git a/fuzzing/old_crashes/direct_parse/array.json b/fuzzing/old_crashes/array.json similarity index 100% rename from fuzzing/old_crashes/direct_parse/array.json rename to fuzzing/old_crashes/array.json diff --git a/fuzzing/old_crashes/parser/clusterfuzz-testcase-minimized-fuzz_parser-4763163676508160 b/fuzzing/old_crashes/clusterfuzz-testcase-minimized-fuzz_parser-4763163676508160 similarity index 100% rename from fuzzing/old_crashes/parser/clusterfuzz-testcase-minimized-fuzz_parser-4763163676508160 rename to fuzzing/old_crashes/clusterfuzz-testcase-minimized-fuzz_parser-4763163676508160 diff --git a/fuzzing/old_crashes/parser/clusterfuzz-testcase-minimized-fuzz_parser-6038712407425024 b/fuzzing/old_crashes/clusterfuzz-testcase-minimized-fuzz_parser-6038712407425024 similarity index 100% rename from fuzzing/old_crashes/parser/clusterfuzz-testcase-minimized-fuzz_parser-6038712407425024 rename to fuzzing/old_crashes/clusterfuzz-testcase-minimized-fuzz_parser-6038712407425024 diff --git a/fuzzing/old_crashes/parser/clusterfuzz-testcase-minimized-fuzz_parser-6157345913700352 b/fuzzing/old_crashes/clusterfuzz-testcase-minimized-fuzz_parser-6157345913700352 similarity index 100% rename from fuzzing/old_crashes/parser/clusterfuzz-testcase-minimized-fuzz_parser-6157345913700352 rename to fuzzing/old_crashes/clusterfuzz-testcase-minimized-fuzz_parser-6157345913700352 diff --git a/fuzzing/old_crashes/basic_parser/crash_00.json b/fuzzing/old_crashes/crash_00.json similarity index 100% rename from fuzzing/old_crashes/basic_parser/crash_00.json rename to fuzzing/old_crashes/crash_00.json diff --git a/fuzzing/old_crashes/basic_parser/crash_01.json b/fuzzing/old_crashes/crash_01.json similarity index 100% rename from fuzzing/old_crashes/basic_parser/crash_01.json rename to fuzzing/old_crashes/crash_01.json diff --git a/fuzzing/old_crashes/basic_parser/gh13_1.json b/fuzzing/old_crashes/gh13_1.json similarity index 100% rename from fuzzing/old_crashes/basic_parser/gh13_1.json rename to fuzzing/old_crashes/gh13_1.json diff --git a/fuzzing/old_crashes/basic_parser/gh13_3.json b/fuzzing/old_crashes/gh13_3.json similarity index 100% rename from fuzzing/old_crashes/basic_parser/gh13_3.json rename to fuzzing/old_crashes/gh13_3.json diff --git a/fuzzing/old_crashes/basic_parser/gh20_0.json b/fuzzing/old_crashes/gh20_0.json similarity index 100% rename from fuzzing/old_crashes/basic_parser/gh20_0.json rename to fuzzing/old_crashes/gh20_0.json diff --git a/fuzzing/old_crashes/basic_parser/gh21_0.json b/fuzzing/old_crashes/gh21_0.json similarity index 100% rename from fuzzing/old_crashes/basic_parser/gh21_0.json rename to fuzzing/old_crashes/gh21_0.json diff --git a/fuzzing/old_crashes/parse/gh221.json b/fuzzing/old_crashes/gh221.json similarity index 100% rename from fuzzing/old_crashes/parse/gh221.json rename to fuzzing/old_crashes/gh221.json diff --git a/fuzzing/old_crashes/basic_parser/minimized-from-58a10325bce45df3e0b4988f932e5a400a344687 b/fuzzing/old_crashes/minimized-from-58a10325bce45df3e0b4988f932e5a400a344687 similarity index 100% rename from fuzzing/old_crashes/basic_parser/minimized-from-58a10325bce45df3e0b4988f932e5a400a344687 rename to fuzzing/old_crashes/minimized-from-58a10325bce45df3e0b4988f932e5a400a344687 diff --git a/fuzzing/old_crashes/direct_parse/tuple.json b/fuzzing/old_crashes/tuple.json similarity index 100% rename from fuzzing/old_crashes/direct_parse/tuple.json rename to fuzzing/old_crashes/tuple.json diff --git a/fuzzing/old_crashes/direct_parse/valid_cxx14.json b/fuzzing/old_crashes/valid_cxx14.json similarity index 100% rename from fuzzing/old_crashes/direct_parse/valid_cxx14.json rename to fuzzing/old_crashes/valid_cxx14.json diff --git a/fuzzing/old_crashes/direct_parse/valid_cxx17.json b/fuzzing/old_crashes/valid_cxx17.json similarity index 100% rename from fuzzing/old_crashes/direct_parse/valid_cxx17.json rename to fuzzing/old_crashes/valid_cxx17.json