on master help sign in
Moved process count-down to terminate function for the C RTS

Some threads exit by finishing the runThread function, and some finish by calling idris_stopThread. The test io003 triggered the assert in runThread. Bring back calling terminate from the end of runThread.

commit72bcc273e635c5f9c6adbd4c9a37f8d4c5947e73 authorJonas Claeson <jonas.cl@protonmail.com> dateTue 9 Apr 2019, 17:40 (8 years ago) parent4b918b1
1 file changed+6−4
rts/idris_rts.c+6−4
rts/idris_rts.c+6−4
@@ -141,6 +141,9 @@ Stats terminate(VM* vm) {
141141 pthread_mutex_destroy(&(vm->alloc_lock));
142142 pthread_cond_destroy(&(vm->inbox_waiting));
143143 free(vm->inbox);
144+ if (vm->creator != NULL) {
145+ vm->creator->processes--;
146+ }
144147#endif
145148 // free(vm);
146149 // Set the VM as inactive, so that if any message gets sent to it
@@ -801,7 +804,9 @@ void* runThread(void* arg) {
801804 free(td);
802805 fn(vm, NULL);
803806
804− assert(0); // will not be reached
807+ // Stats stats =
808+ terminate(vm);
809+ // aggregate_stats(&(td->vm->stats), &stats);
805810 return NULL;
806811}
807812
@@ -837,9 +842,6 @@ void* vmThread(VM* callvm, func f, VAL arg) {
837842}
838843
839844void* idris_stopThread(VM* vm) {
840− if (vm->creator != NULL) {
841− vm->creator->processes--;
842− }
843845 terminate(vm);
844846 pthread_exit(NULL);
845847 return NULL;