From 1156977958b0c87d5d473fd97fd105ba2ea4704e Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Sun, 13 Dec 2020 11:05:36 -0500 Subject: [PATCH] Issue #425 - Raise a scheme error instead of allowing the runtime to segfault --- CHANGELOG.md | 4 ++++ runtime.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7ad1957..69e159b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.24 - TBD +Bug Fixes + +- Do not attempt to call `eval` from the runtime if `(scheme eval)` has not been imported. We not raise a Scheme error instead of risking a C segmentation violation. + ## 0.23 - December 1, 2020 Bug Fixes diff --git a/runtime.c b/runtime.c index 44420d26..55c64654 100644 --- a/runtime.c +++ b/runtime.c @@ -5639,7 +5639,7 @@ object apply(void *data, object cont, object func, object args) if (!is_object_type(fobj) || type_of(fobj) != symbol_tag) { Cyc_rt_raise2(data, "Call of non-procedure: ", func); - } else if (strncmp(((symbol) fobj)->desc, "lambda", 7) == 0) { + } else if (strncmp(((symbol) fobj)->desc, "lambda", 7) == 0 && Cyc_glo_eval_from_c != NULL) { make_pair(c, func, args); //printf("JAE DEBUG, sending to eval: "); //Cyc_display(data, &c, stderr); @@ -5649,11 +5649,11 @@ object apply(void *data, object cont, object func, object args) // TODO: would be better to compare directly against symbols here, // but need a way of looking them up ahead of time. // maybe a libinit() or such is required. - } else if (strncmp(((symbol) fobj)->desc, "primitive", 10) == 0) { + } else if (strncmp(((symbol) fobj)->desc, "primitive", 10) == 0 && Cyc_glo_eval_from_c != NULL) { make_pair(c, cadr(func), args); ((closure) Cyc_glo_eval_from_c)->fn(data, 3, Cyc_glo_eval_from_c, cont, &c, NULL); - } else if (strncmp(((symbol) fobj)->desc, "procedure", 10) == 0) { + } else if (strncmp(((symbol) fobj)->desc, "procedure", 10) == 0 && Cyc_glo_eval_from_c != NULL) { make_pair(c, func, args); ((closure) Cyc_glo_eval_from_c)->fn(data, 3, Cyc_glo_eval_from_c, cont, &c, NULL);