Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: don't exit the main thread if a coexp attempted to gc it #362

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/runtime/rcoexpr.r
Original file line number Diff line number Diff line change
Expand Up @@ -577,19 +577,25 @@ void coclean(struct b_coexpr *cp) {

if (!IS_TS_THREAD(cp->status) || cp->alive==-1){
CURTSTATE();
cp->alive = -1; /* signal thread to exit */

#ifdef Concurrent
if (cp->id==curtstate->c->id){
/*
* If the thread is cleaning itself, exit, what about tls chain?
*/
cp->have_thread = 0;
#ifndef NO_COEXPR_SEMAPHORE_FIX
if (cp->semp) {SEM_CLOSE(cp->semp); cp->semp = NULL;}
#endif /* NO_COEXPR_SEMAPHORE_FIX */
pthread_exit(0);
}
if (cp == curtstate->c) {
/*
* If the thread is cleaning itself, exit, what about tls chain?
*/
cp->alive = -1; /* signal thread to exit */
cp->have_thread = 0;
#ifndef NO_COEXPR_SEMAPHORE_FIX
if (cp->semp) {SEM_CLOSE(cp->semp); cp->semp = NULL;}
#endif /* NO_COEXPR_SEMAPHORE_FIX */
pthread_exit(0);
} else if (cp->id == 1 && cp->id == curtstate->c->id) {
/* FIXME: Main thread, should just return? */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this FIXME be here? If yes, it's new code; why aren't we fixing it now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left it there intentionally because I wasn't there if this has any side effects.

return;
}
#endif /* Concurrent */

cp->alive = -1; /* signal thread to exit */
if (cp->have_thread){
sem_post(cp->semp); /* unblock it */
THREAD_JOIN(cp->thread, NULL); /* wait for thread to exit */
Expand Down
Loading