-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(saver): flex-1 and flint-1 in kupl/starlab-benchmarks (#2)
- Loading branch information
1 parent
8cae563
commit bdda2d4
Showing
4 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"context": "context/saver/starlab-benchmarks", | ||
"name": "saver", | ||
"tag": "flex-1", | ||
"build_args": { | ||
"BENCHMARK": "ghcr.io/kupl/starlab-benchmarks/c:flex-1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"context": "context/saver/starlab-benchmarks", | ||
"name": "saver", | ||
"tag": "flint-1", | ||
"build_args": { | ||
"BENCHMARK": "ghcr.io/kupl/starlab-benchmarks/c:flint-1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ARG BENCHMARK_IMAGE | ||
FROM ${BENCHMARK_IMAGE} | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get update \ | ||
&& apt-get install -y \ | ||
build-essential \ | ||
git \ | ||
jq \ | ||
libtinfo5 \ | ||
libz3-dev \ | ||
python \ | ||
python3 \ | ||
tzdata \ | ||
wget \ | ||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/list/* | ||
|
||
WORKDIR /opt | ||
RUN wget https://koreaoffice-my.sharepoint.com/:u:/g/personal/seongjoon_korea_ac_kr/ETNyGJaRxbFEgA_IHJLyRQ0BQ9egwDuxCnpjdt4AmNHlVw\?e\=KGhbVN\&download\=1 -O saver.tar.gz \ | ||
&& tar -xvf saver.tar.gz \ | ||
rm saver.tar.gz | ||
|
||
ENV PATH=/opt/saver-1.0/infer/bin:${PATH} | ||
|
||
WORKDIR /workspace | ||
COPY ./scripts/ /tmp/scripts/ | ||
RUN python3 /tmp/scripts/bootstrap.py metadata.json \ | ||
&& rm -rf /tmp/scripts |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import json | ||
import sys | ||
from pathlib import Path | ||
|
||
argv = sys.argv | ||
if len(argv) < 2: | ||
print("Usage: python bootstrap.py <metadata.json>") | ||
exit(1) | ||
|
||
metadata = json.loads(Path(argv[1]).read_text()) | ||
if ( | ||
"memory-leak" not in metadata["categories"] | ||
or "resource-leak" not in metadata["categories"] | ||
): | ||
print("This benchmark is not supported by SAVER.") | ||
exit(1) | ||
|
||
basedir = Path() / metadata["buggy"] | ||
|
||
report = { | ||
"err_type": "MEMORY_LEAK", | ||
"source": { | ||
"filepath": metadata["leak"]["source"]["file"], | ||
"line": metadata["leak"]["source"]["line"], | ||
}, | ||
"sink": { | ||
"filepath": metadata["leak"]["sink"]["file"], | ||
"line": metadata["leak"]["sink"]["line"], | ||
}, | ||
} | ||
report_json = basedir / "report.json" | ||
report_json.write_text(json.dumps(report, indent=4)) | ||
|
||
|
||
def make_effect(event, effect, reference_depth): | ||
return { | ||
"deref": reference_depth > 0, | ||
"event": event, | ||
"idx": 0 if effect == "$return" else int(effect.removeprefix("$param")), | ||
} | ||
|
||
|
||
if "resource-leak" in metadata["categories"]: | ||
apispec = [] | ||
for kind, spec in metadata["api"].items(): | ||
api = { | ||
"resource-type": kind, | ||
"allocators": [], | ||
"deallocators": [], | ||
} | ||
for alloc in spec["allocators"]: | ||
alloc = { | ||
"method_name": alloc["func"], | ||
"param_effects": [], | ||
"param_types": [], | ||
"return_effect": None, | ||
} | ||
effect = make_effect("Alloc", alloc["effect"], alloc["reference_depth"]) | ||
if alloc["effect"] != "$return": | ||
alloc["param_effects"].append(effect) | ||
alloc["return_effect"] = {"deref": False, "event": "", "idx": 0} | ||
else: | ||
alloc["return_effect"] = effect | ||
api["allocators"].append(alloc) | ||
for dealloc in spec["deallocators"]: | ||
dealloc = { | ||
"method_name": dealloc["func"], | ||
"param_effects": [], | ||
"param_types": [], | ||
"return_effect": None, | ||
} | ||
effect = make_effect("Free", dealloc["effect"], dealloc["reference_depth"]) | ||
if dealloc["effect"] != "$return": | ||
dealloc["param_effects"].append(effect) | ||
dealloc["return_effect"] = {"deref": False, "event": "", "idx": 0} | ||
else: | ||
dealloc["return_effect"] = effect | ||
api["deallocators"].append(dealloc) | ||
apispec.append(api) | ||
apispec_json = basedir / "api.json" | ||
apispec_json.write_text(json.dumps(apispec, indent=4)) |