Skip to content

Commit a9006bd

Browse files
author
Ubuntu
committed
updated feedback event listener to capture complete line:
:
1 parent e468141 commit a9006bd

6 files changed

Lines changed: 121 additions & 80 deletions

File tree

Sources/Fuzzilli/Modules/Storage.swift

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,35 @@ public class Storage: Module {
118118
let filename = "\(ev.name)_\(ev.programId)"
119119
let url = URL(fileURLWithPath: "\(self.feedbackDir)/\(filename).fu") // feedback vector update
120120

121-
// filter and append lines to the file
121+
// collect complete feedback blocks that start with needle and have balanced brackets
122122
let lines = contentStr.split(separator: "\n", omittingEmptySubsequences: false)
123123
var matched = [String]()
124+
var currentBlock = ""
125+
var openCount = 0
126+
var collecting = false
127+
124128
for line in lines {
125-
if line.contains(needle) {
126-
matched.append(String(line))
129+
let lineStr = String(line)
130+
131+
// start collecting when we find the needle
132+
if lineStr.contains(needle) {
133+
collecting = true
134+
}
135+
136+
if collecting {
137+
currentBlock += lineStr + "\n"
138+
139+
// count brackets in this line
140+
let opens = lineStr.filter { $0 == "[" }.count
141+
let closes = lineStr.filter { $0 == "]" }.count
142+
openCount += opens - closes
143+
144+
// when brackets are balanced, we have a complete feedback block
145+
if openCount == 0 && !currentBlock.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
146+
matched.append(currentBlock.trimmingCharacters(in: .whitespacesAndNewlines))
147+
currentBlock = ""
148+
collecting = false
149+
}
127150
}
128151
}
129152
guard !matched.isEmpty else { return }
@@ -138,6 +161,7 @@ public class Storage: Module {
138161
}
139162
}
140163

164+
141165
if fuzzer.config.enableDiagnostics {
142166
fuzzer.registerEventListener(for: fuzzer.events.DiagnosticsEvent) { ev in
143167
let filename = "\(self.formatDate())_\(ev.name)_\(String(currentMillis()))"

Targets/V8/fuzzbuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
if [ "$(uname)" == "Linux" ]; then
1818
# See https://v8.dev/docs/compile-arm64 for instructions on how to build on Arm64
19-
gn gen out/fuzzbuild --args='is_debug=true v8_symbol_level=2 v8_enable_i18n_support=false dcheck_always_on=true v8_static_library=true v8_enable_verify_heap=true v8_fuzzilli=true sanitizer_coverage_flags="trace-pc-guard" target_cpu="x64" v8_enable_trace_feedback_updates=true'
19+
gn gen out/fuzzbuild --args='is_debug=false v8_enable_i18n_support=false dcheck_always_on=true v8_static_library=true v8_enable_verify_heap=true v8_fuzzilli=true sanitizer_coverage_flags="trace-pc-guard" target_cpu="x64" '
2020
else
2121
echo "Unsupported operating system"
2222
fi

Targets/V8/fuzzbuild_dbg.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2019 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https:#www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
if [ "$(uname)" == "Linux" ]; then
18+
# See https://v8.dev/docs/compile-arm64 for instructions on how to build on Arm64
19+
gn gen out/fuzzbuild_dbg --args='is_debug=true v8_symbol_level=2 v8_enable_i18n_support=false dcheck_always_on=true v8_static_library=true v8_enable_verify_heap=true v8_fuzzilli=true sanitizer_coverage_flags="trace-pc-guard" target_cpu="x64" v8_enable_trace_feedback_updates=true'
20+
else
21+
echo "Unsupported operating system"
22+
fi
23+
24+
ninja -C ./out/fuzzbuild_dbg -j$(nproc) d8

runFuzzilli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
swift run FuzzilliCli --profile=v8 --engine=multi --resume --corpus=redis --storagePath=./Corpus --logLevel=verbose --timeout=1500 --diagnostics /home/diddy/v8/v8/out/fuzzbuild/d8
1+
swift run FuzzilliCli --profile=v8debug --engine=multi --resume --corpus=basic --storagePath=./Corpus --logLevel=verbose --timeout=1500 --diagnostics /home/diddy/v8/v8/out/fuzzbuild/d8

turbo.cfg

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +0,0 @@
1-
begin_compilation
2-
name "F61"
3-
method "F61:1"
4-
date 1759471932
5-
end_compilation
6-
begin_compilation
7-
name "F61"
8-
method "F61:6"
9-
date 1759471933
10-
end_compilation
11-
begin_compilation
12-
name "F61"
13-
method "F61:12"
14-
date 1759471933
15-
end_compilation
16-
begin_compilation
17-
name "F61"
18-
method "F61:18"
19-
date 1759471933
20-
end_compilation
21-
begin_compilation
22-
name "F61"
23-
method "F61:24"
24-
date 1759471933
25-
end_compilation
26-
begin_compilation
27-
name "F61"
28-
method "F61:30"
29-
date 1759471933
30-
end_compilation
31-
begin_compilation
32-
name "F61"
33-
method "F61:36"
34-
date 1759471933
35-
end_compilation
36-
begin_compilation
37-
name "F61"
38-
method "F61:42"
39-
date 1759471933
40-
end_compilation
41-
begin_compilation
42-
name "F61"
43-
method "F61:48"
44-
date 1759471934
45-
end_compilation
46-
begin_compilation
47-
name "F61"
48-
method "F61:54"
49-
date 1759471934
50-
end_compilation
51-
begin_compilation
52-
name "F61"
53-
method "F61:60"
54-
date 1759471934
55-
end_compilation
56-
begin_compilation
57-
name "F61"
58-
method "F61:66"
59-
date 1759471934
60-
end_compilation
61-
begin_compilation
62-
name "F61"
63-
method "F61:72"
64-
date 1759471934
65-
end_compilation
66-
begin_compilation
67-
name "F61"
68-
method "F61:78"
69-
date 1759471934
70-
end_compilation
71-
begin_compilation
72-
name "F61"
73-
method "F61:84"
74-
date 1759471934
75-
end_compilation

vrig_docker/sync.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import asyncio, os, time
2+
from redis.asyncio import Redis
3+
import asyncpg
4+
5+
GROUP = os.getenv("GROUP", "g_fuzz")
6+
CONSUMER = os.getenv("CONSUMER", "c_sync_1")
7+
STREAMS = os.getenv("STREAMS", "redis1=redis://redis1:6379,redis2=redis://redis2:6379").split(",")
8+
STREAM_NAME = "stream:fuzz:updates"
9+
PG_DSN = os.getenv("PG_DSN", "postgres://fuzzuser:pass@pg:5432/main")
10+
11+
CREATE_GROUP_OK = {"OK", "BUSYGROUP Consumer Group name already exists"}
12+
13+
UPSERT_SQL = """
14+
INSERT INTO fuzz_data (key, val, origin, vclock, updated_at)
15+
VALUES ($1, $2, $3, $4, NOW())
16+
ON CONFLICT (key) DO UPDATE SET
17+
val = CASE WHEN EXCLUDED.vclock >= fuzz_data.vclock THEN EXCLUDED.val ELSE fuzz_data.val END,
18+
origin = CASE WHEN EXCLUDED.vclock >= fuzz_data.vclock THEN EXCLUDED.origin ELSE fuzz_data.origin END,
19+
vclock = GREATEST(fuzz_data.vclock, EXCLUDED.vclock),
20+
updated_at = CASE WHEN EXCLUDED.vclock >= fuzz_data.vclock THEN NOW() ELSE fuzz_data.updated_at END;
21+
"""
22+
23+
async def ensure_group(r: Redis, stream: str):
24+
try:
25+
await r.xgroup_create(stream, GROUP, id="$", mkstream=True)
26+
except Exception as e:
27+
if "BUSYGROUP" not in str(e):
28+
raise
29+
30+
async def consume_stream(label: str, redis_url: str, pg):
31+
r = Redis.from_url(redis_url)
32+
await ensure_group(r, STREAM_NAME)
33+
while True:
34+
try:
35+
# Read new messages for this consumer
36+
resp = await r.xreadgroup(GROUP, CONSUMER, {STREAM_NAME: ">"}, count=100, block=5000)
37+
if not resp:
38+
continue
39+
# resp = [(b'stream:fuzz:updates', [(id, {b'k':b'v', ...}), ...])]
40+
for _, entries in resp:
41+
for msg_id, data in entries:
42+
op = data.get(b'op', b'').decode()
43+
key = data.get(b'key', b'').decode()
44+
origin = data.get(b'origin', b'').decode()
45+
vclock = int(data.get(b'vclock', b'0').decode() or 0)
46+
if op == "del":
47+
# Represent deletes: write NULL / tombstone (optional)
48+
await pg.execute(
49+
"DELETE FROM fuzz_data WHERE key=$1 AND vclock <= $2", key, vclock
50+
)
51+
else:
52+
val = data.get(b'val', b'')
53+
await pg.execute(UPSERT_SQL, key, val, origin, vclock)
54+
await r.xack(STREAM_NAME, GROUP, msg_id)
55+
except Exception as e:
56+
# backoff on errors
57+
await asyncio.sleep(1)
58+
59+
async def main():
60+
pg = await asyncpg.connect(PG_DSN)
61+
tasks = []
62+
for pair in STREAMS:
63+
label, url = pair.split("=")
64+
tasks.append(asyncio.create_task(consume_stream(label, url, pg)))
65+
await asyncio.gather(*tasks)
66+
67+
if __name__ == "__main__":
68+
asyncio.run(main())

0 commit comments

Comments
 (0)