From 97f3f141a0670715c61ff15b5d39f2cc56720b44 Mon Sep 17 00:00:00 2001 From: Henry Lee Date: Wed, 15 Nov 2023 17:14:55 +0900 Subject: [PATCH] fix(c): fix dockerfile and scripts for saver --- configures/saver/flex-1.json | 2 +- configures/saver/flint-1.json | 2 +- context/saver/starlab-benchmarks/Dockerfile | 2 +- .../starlab-benchmarks/scripts/bootstrap.py | 30 +++++++++++-------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/configures/saver/flex-1.json b/configures/saver/flex-1.json index ab1a276..83516e1 100644 --- a/configures/saver/flex-1.json +++ b/configures/saver/flex-1.json @@ -5,4 +5,4 @@ "build_args": { "BENCHMARK_IMAGE": "ghcr.io/kupl/starlab-benchmarks/c:flex-1" } -} \ No newline at end of file +} diff --git a/configures/saver/flint-1.json b/configures/saver/flint-1.json index c4d2d50..7543638 100644 --- a/configures/saver/flint-1.json +++ b/configures/saver/flint-1.json @@ -5,4 +5,4 @@ "build_args": { "BENCHMARK_IMAGE": "ghcr.io/kupl/starlab-benchmarks/c:flint-1" } -} \ No newline at end of file +} diff --git a/context/saver/starlab-benchmarks/Dockerfile b/context/saver/starlab-benchmarks/Dockerfile index c6fcadd..eae17f2 100644 --- a/context/saver/starlab-benchmarks/Dockerfile +++ b/context/saver/starlab-benchmarks/Dockerfile @@ -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} diff --git a/context/saver/starlab-benchmarks/scripts/bootstrap.py b/context/saver/starlab-benchmarks/scripts/bootstrap.py index 9a3ca7a..bbe030f 100644 --- a/context/saver/starlab-benchmarks/scripts/bootstrap.py +++ b/context/saver/starlab-benchmarks/scripts/bootstrap.py @@ -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", @@ -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")), } @@ -49,7 +53,7 @@ def make_effect(event, effect, reference_depth): "deallocators": [], } for alloc in spec["allocators"]: - alloc = { + allocator = { "method_name": alloc["func"], "param_effects": [], "param_types": [], @@ -57,13 +61,13 @@ def make_effect(event, effect, reference_depth): } 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": [], @@ -71,11 +75,11 @@ def make_effect(event, effect, reference_depth): } 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))