Skip to content

Instantly share code, notes, and snippets.

@mertyildiran
Created October 9, 2020 08:36
Show Gist options
  • Save mertyildiran/8134e953af09e8031df31f546bdc784e to your computer and use it in GitHub Desktop.
Save mertyildiran/8134e953af09e8031df31f546bdc784e to your computer and use it in GitHub Desktop.
Fix to Valgrind & longjmp issue in Chaos language
diff --git a/interpreter/errors.c b/interpreter/errors.c
index 53e082d..b0161dd 100644
--- a/interpreter/errors.c
+++ b/interpreter/errors.c
@@ -173,7 +173,7 @@ void throw_error_base(unsigned short code, char *str1, char *str2, long long lld
exit(code);
} else {
#ifndef CHAOS_COMPILER
- longjmp(InteractiveShellErrorAbsorber, 1);
+ absorbError();
#endif
}
}
diff --git a/interpreter/errors.h b/interpreter/errors.h
index a904057..ce964fd 100644
--- a/interpreter/errors.h
+++ b/interpreter/errors.h
@@ -46,6 +46,7 @@ enum ExitCode {
};
extern void freeEverything();
+extern void absorbError();
extern bool is_interactive;
extern jmp_buf InteractiveShellErrorAbsorber;
diff --git a/parser/parser.c b/parser/parser.c
index b82e138..cdb0deb 100644
--- a/parser/parser.c
+++ b/parser/parser.c
@@ -117,7 +117,6 @@ int initParser(int argc, char** argv) {
do {
if (is_interactive) {
if (setjmp(InteractiveShellErrorAbsorber)) {
- absorbError();
}
}
@@ -236,6 +235,8 @@ void absorbError() {
free(main_interpreted_module);
main_interpreted_module = NULL;
}
+
+ longjmp(InteractiveShellErrorAbsorber, 1);
}
void throwCompilerInteractiveError() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment