Skip to content

Commit

Permalink
fix(c): fix dockerfile and scripts for saver
Browse files Browse the repository at this point in the history
  • Loading branch information
henrylee97 committed Nov 15, 2023
1 parent cd0ee8a commit 97f3f14
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion configures/saver/flex-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"build_args": {
"BENCHMARK_IMAGE": "ghcr.io/kupl/starlab-benchmarks/c:flex-1"
}
}
}
2 changes: 1 addition & 1 deletion configures/saver/flint-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"build_args": {
"BENCHMARK_IMAGE": "ghcr.io/kupl/starlab-benchmarks/c:flint-1"
}
}
}
2 changes: 1 addition & 1 deletion context/saver/starlab-benchmarks/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
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
&& rm saver.tar.gz

ENV PATH=/opt/saver-1.0/infer/bin:${PATH}

Expand Down
30 changes: 17 additions & 13 deletions context/saver/starlab-benchmarks/scripts/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
metadata = json.loads(Path(argv[1]).read_text())
if (
"memory-leak" not in metadata["categories"]
or "resource-leak" not in metadata["categories"]
and "resource-leak" not in metadata["categories"]
):
print("This benchmark is not supported by SAVER.")
exit(1)

basedir = Path() / metadata["buggy"]
basedir = Path() / metadata["buggyPath"]

report = {
"err_type": "MEMORY_LEAK",
Expand All @@ -31,12 +31,16 @@
report_json = basedir / "report.json"
report_json.write_text(json.dumps(report, indent=4))

def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text

def make_effect(event, effect, reference_depth):
return {
"deref": reference_depth > 0,
"event": event,
"idx": 0 if effect == "$return" else int(effect.removeprefix("$param")),
"idx": 0 if effect == "$return" else int(remove_prefix(effect, "$param")),
}


Expand All @@ -49,33 +53,33 @@ def make_effect(event, effect, reference_depth):
"deallocators": [],
}
for alloc in spec["allocators"]:
alloc = {
allocator = {
"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}
allocator["param_effects"].append(effect)
allocator["return_effect"] = {"deref": False, "event": "", "idx": 0}
else:
alloc["return_effect"] = effect
api["allocators"].append(alloc)
allocator["return_effect"] = effect
api["allocators"].append(allocator)
for dealloc in spec["deallocators"]:
dealloc = {
deallocator = {
"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}
deallocator["param_effects"].append(effect)
deallocator["return_effect"] = {"deref": False, "event": "", "idx": 0}
else:
dealloc["return_effect"] = effect
api["deallocators"].append(dealloc)
deallocator["return_effect"] = effect
api["deallocators"].append(deallocator)
apispec.append(api)
apispec_json = basedir / "api.json"
apispec_json.write_text(json.dumps(apispec, indent=4))

0 comments on commit 97f3f14

Please sign in to comment.