Skip to content

Commit

Permalink
unbreak system in a thread that has interrupts disabled (#766)
Browse files Browse the repository at this point in the history
Fixes a mistake in d7cc2cf. This mistake was noticed by some C
compilers, but I missed the warnings.
  • Loading branch information
mflatt authored Nov 23, 2023
1 parent 2c700cf commit 575feda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions c/prim5.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,9 @@ static void s_showalloc(IBOOL show_dump, const char *outfn) {

static ptr s_system(const char *s) {
INT status;
char *s_arg;
#ifdef PTHREADS
ptr tc = get_thread_context();
char *s_arg = NULL;
#endif

#ifdef PTHREADS
Expand All @@ -725,11 +725,11 @@ static ptr s_system(const char *s) {
S_error("system", "malloc failed");
memcpy(s_arg, s, len);
deactivate_thread(tc);
}
#else
s_arg = (char *)s;
s = s_arg;
} else
s_arg = NULL;
#endif
status = SYSTEM(s_arg);
status = SYSTEM(s);
#ifdef PTHREADS
if (DISABLECOUNT(tc) == FIX(0)) {
reactivate_thread(tc);
Expand Down
5 changes: 5 additions & 0 deletions mats/unix.ms
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,11 @@
(unless (or (windows?)
(not (threaded?)))
(mat thread-system

;; make sure `system` works when interrupts are disabled
(with-interrupts-disabled
(eqv? 0 (system "echo hi")))

;; check that when a thread is deactivated during `system`,
;; the command that it's running isn't GCed
(let* ([count 50]
Expand Down

0 comments on commit 575feda

Please sign in to comment.