From fa541aff31a4c8752f2dc033e100f22588ce2ac0 Mon Sep 17 00:00:00 2001 From: Ben Albrecht Date: Fri, 4 Sep 2020 11:19:16 -0500 Subject: [PATCH] Work-around TOML bug in mason and add a future for bug TOML can produce a seg fault when parsing a file containing only a comment. Mason search added a cache file containing only a comment if a cache file did not exist. To work around this bug, we just create an empty cache file. Also added a future for the TOML bug --- test/library/packages/TOML/test/commentOnly.chpl | 11 +++++++++++ test/library/packages/TOML/test/commentOnly.future | 2 ++ test/library/packages/TOML/test/commentOnly.good | 0 test/mason/search/badFileName/CLEANFILES | 1 + tools/mason/MasonSearch.chpl | 3 +-- 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test/library/packages/TOML/test/commentOnly.chpl create mode 100644 test/library/packages/TOML/test/commentOnly.future create mode 100644 test/library/packages/TOML/test/commentOnly.good create mode 100644 test/mason/search/badFileName/CLEANFILES diff --git a/test/library/packages/TOML/test/commentOnly.chpl b/test/library/packages/TOML/test/commentOnly.chpl new file mode 100644 index 000000000000..b869b10d7a74 --- /dev/null +++ b/test/library/packages/TOML/test/commentOnly.chpl @@ -0,0 +1,11 @@ +use TOML; + +config const str: string = """# Comment"""; + +proc main() { + var TomlData = parseToml(str); + writeln(TomlData); + delete TomlData; +} + + diff --git a/test/library/packages/TOML/test/commentOnly.future b/test/library/packages/TOML/test/commentOnly.future new file mode 100644 index 000000000000..659e5a2e6fd2 --- /dev/null +++ b/test/library/packages/TOML/test/commentOnly.future @@ -0,0 +1,2 @@ +bug: TOML containing only comments produces memory errors (caught in valgrind) + diff --git a/test/library/packages/TOML/test/commentOnly.good b/test/library/packages/TOML/test/commentOnly.good new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/mason/search/badFileName/CLEANFILES b/test/mason/search/badFileName/CLEANFILES new file mode 100644 index 000000000000..9b6f5355183f --- /dev/null +++ b/test/mason/search/badFileName/CLEANFILES @@ -0,0 +1 @@ +mason_home/mason-registry/Bricks/cache.toml diff --git a/tools/mason/MasonSearch.chpl b/tools/mason/MasonSearch.chpl index 79f719313321..97401f2a4389 100644 --- a/tools/mason/MasonSearch.chpl +++ b/tools/mason/MasonSearch.chpl @@ -169,8 +169,7 @@ proc rankResults(results: list(string), query: string): [] string { /* Creates an empty cache file if its not found in registry */ proc touch(pathToReg: string) { const fileWriter = open(pathToReg, iomode.cw).writer(); - const contents = "# This cache file was created automatically by mason search"; - fileWriter.write(contents); + fileWriter.write(""); fileWriter.close(); }