-
Notifications
You must be signed in to change notification settings - Fork 0
Add JSON encode fuzz runner #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
617b216
deacb38
1f6cebd
47a0ab1
886cb3b
78507ab
5872048
e7f9e4c
f61898a
4501a83
ca5b742
1d00333
16f843b
6a2ab74
51d17fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| .PHONY: fuzz | ||
|
|
||
| LUA ?= lua | ||
| DURATION ?= 3600 | ||
| INTERVAL ?= 5 | ||
| WORKERS ?= 1 | ||
| SEED ?= $(shell date +%s) | ||
| SORT_KEYS ?= 1 | ||
| SAMPLE_INTERVAL ?= 0 | ||
| SAMPLE_LIMIT ?= | ||
|
|
||
| fuzz: | ||
| @set -u; \ | ||
| tmpdir=$$(mktemp -d "$${TMPDIR:-/tmp}/lua-rapidjson-fuzz.XXXXXX"); \ | ||
| pids=""; \ | ||
| cleanup() { rm -rf "$$tmpdir"; }; \ | ||
| stop_workers() { for pid in $$pids; do kill "$$pid" 2>/dev/null || true; done; cleanup; }; \ | ||
| trap cleanup EXIT; \ | ||
| trap stop_workers INT TERM; \ | ||
| worker=1; \ | ||
| while [ "$$worker" -le "$(WORKERS)" ]; do \ | ||
| seed=$$(( $(SEED) + $$worker - 1 )); \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify mismatch between Makefile arithmetic requirement and fuzz lib seed normalization.
rg -n -C2 'seed=\$\$\(\(|SEED' Makefile
rg -n -C3 'normalize_seed|tonumber\(|SEED' tools/fuzz_encode_lib.luaRepository: api7/lua-rapidjson Length of output: 1770 🏁 Script executed: #!/bin/bash
# Inspect Makefile around SEED and seed arithmetic.
sed -n '1,60p' Makefile
# Find other SEED usage in repo.
rg -n 'SEED\b' Makefile tools -SRepository: api7/lua-rapidjson Length of output: 1750 🏁 Script executed: #!/bin/bash
# Inspect how SEED is passed into Lua and normalized.
sed -n '1,120p' tools/fuzz_encode.lua
sed -n '1,120p' tools/fuzz_encode_lib.luaRepository: api7/lua-rapidjson Length of output: 4798 Coerce 🤖 Prompt for AI Agents |
||
| ( \ | ||
| DURATION="$(DURATION)" \ | ||
| INTERVAL="$(INTERVAL)" \ | ||
| WORKERS="$(WORKERS)" \ | ||
| WORKER_ID="$$worker" \ | ||
| SEED="$$seed" \ | ||
| SORT_KEYS="$(SORT_KEYS)" \ | ||
| SAMPLE_INTERVAL="$(SAMPLE_INTERVAL)" \ | ||
| SAMPLE_LIMIT="$(SAMPLE_LIMIT)" \ | ||
| "$(LUA)" tools/fuzz_encode.lua; \ | ||
| rc=$$?; \ | ||
| if [ "$$rc" -ne 0 ]; then \ | ||
| echo "$$rc" > "$$tmpdir/fail.$$worker"; \ | ||
| fi; \ | ||
| echo "$$rc" > "$$tmpdir/done.$$worker"; \ | ||
| ) & \ | ||
| pids="$$pids $$!"; \ | ||
| worker=$$(( $$worker + 1 )); \ | ||
| done; \ | ||
| status=0; \ | ||
| while :; do \ | ||
| if ls "$$tmpdir"/fail.* >/dev/null 2>&1; then \ | ||
| status=1; \ | ||
| for pid in $$pids; do \ | ||
| kill "$$pid" 2>/dev/null || true; \ | ||
| done; \ | ||
| break; \ | ||
| fi; \ | ||
| done_count=$$(ls "$$tmpdir"/done.* 2>/dev/null | wc -l | tr -d ' '); \ | ||
| if [ "$$done_count" -ge "$(WORKERS)" ]; then \ | ||
| break; \ | ||
| fi; \ | ||
| sleep 1; \ | ||
| done; \ | ||
| for pid in $$pids; do \ | ||
| if ! wait "$$pid" 2>/dev/null; then \ | ||
| status=1; \ | ||
| fi; \ | ||
| done; \ | ||
| exit "$$status" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: api7/lua-rapidjson
Length of output: 954
Stop the fuzz polling loop from continuing after INT/TERM cleanup
In
Makefile’sfuzztarget,stop_workers()(lines ~15–17) callscleanup()whichrm -rfs$$tmpdir, but the parentwhile :; dopolling loop (lines ~39–50) keeps waiting onls "$$tmpdir"/fail.*/ls "$$tmpdir"/done.*. After$$tmpdiris removed,fail.*never appears anddone_countstays at0, so the loop can sleep indefinitely.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents