From 99f6357ccd3a74990e3ee97c6b3f7b6200d4fc6f Mon Sep 17 00:00:00 2001 From: IntelliJ User Date: Wed, 21 Aug 2019 18:47:25 +0300 Subject: [PATCH 1/4] Compiled program segfault bugfix --- runtime/runtime.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/runtime/runtime.c b/runtime/runtime.c index f339db8b7..da35cd710 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -316,13 +316,16 @@ extern void* Bsexp (int n, ...) { extern int Btag (void *d, int t, int n) { data *r = (data *) BOX (NULL); - r = TO_DATA(d); + if (UNBOXED(d)) return BOX(0); + else { + r = TO_DATA(d); #ifndef DEBUG_PRINT - return BOX(TAG(r->tag) == SEXP_TAG && TO_SEXP(d)->tag == t && LEN(r->tag) == n); + return BOX(TAG(r->tag) == SEXP_TAG && TO_SEXP(d)->tag == t && LEN(r->tag) == n); #else - return BOX(TAG(r->tag) == SEXP_TAG && + return BOX(TAG(r->tag) == SEXP_TAG && GET_SEXP_TAG(TO_SEXP(d)->tag) == t && LEN(r->tag) == n); #endif + } } extern int Barray_patt (void *d, int n) { From 25e1f55ecdec974b55613f64a37cb829d4163f61 Mon Sep 17 00:00:00 2001 From: IntelliJ User Date: Thu, 22 Aug 2019 12:06:46 +0300 Subject: [PATCH 2/4] test for issue #3 --- regression/orig/test055.log | 2 ++ regression/test055.expr | 8 ++++++++ regression/test055.input | 0 3 files changed, 10 insertions(+) create mode 100644 regression/orig/test055.log create mode 100644 regression/test055.expr create mode 100644 regression/test055.input diff --git a/regression/orig/test055.log b/regression/orig/test055.log new file mode 100644 index 000000000..12decc137 --- /dev/null +++ b/regression/orig/test055.log @@ -0,0 +1,2 @@ +0 +3 diff --git a/regression/test055.expr b/regression/test055.expr new file mode 100644 index 000000000..00b21a292 --- /dev/null +++ b/regression/test055.expr @@ -0,0 +1,8 @@ +fun len(l) { + case l of + _ : xs -> return len(xs) + 1 + |{} -> return 0 + esac +} +write(len({})); +write(len({1, 2, 3})) \ No newline at end of file diff --git a/regression/test055.input b/regression/test055.input new file mode 100644 index 000000000..e69de29bb From d023b44db3491e6670b60a8921bbaf6e01bc4347 Mon Sep 17 00:00:00 2001 From: IntelliJ User Date: Fri, 23 Aug 2019 16:10:56 +0300 Subject: [PATCH 3/4] close #8 --- src/X86.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/X86.ml b/src/X86.ml index b69c360c0..992f5f852 100644 --- a/src/X86.ml +++ b/src/X86.ml @@ -389,7 +389,7 @@ module M = Map.Make (String) (* Environment implementation *) class env = - let chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNJPQRSTUVWXYZ" in + let chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" in let make_assoc l i = List.combine l (List.init (List.length l) (fun x -> x + i)) in let rec assoc x = function [] -> raise Not_found | l :: ls -> try List.assoc x l with Not_found -> assoc x ls in object (self) From e52241d2cef8bc3de8b42ba0e6da944a5190d7c3 Mon Sep 17 00:00:00 2001 From: IntelliJ User Date: Mon, 26 Aug 2019 15:51:12 +0300 Subject: [PATCH 4/4] one more fix to #8 --- runtime/runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/runtime.c b/runtime/runtime.c index da35cd710..a9e51ad70 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -66,7 +66,7 @@ char* de_hash (int n) { static char *chars = (char*) BOX (NULL); static char buf[6] = {0,0,0,0,0,0}; char *p = (char *) BOX (NULL); - chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNJPQRSTUVWXYZ"; + chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; p = &buf[5]; #ifdef DEBUG_PRINT