Skip to content

Commit

Permalink
Fix cycle detector rescheduling bug introduced in ponylang#4607 (pony…
Browse files Browse the repository at this point in the history
…lang#4608)

PR ponylang#4607 introduced a bug causing the cycle detector to be
rescheduled when it didn't need to be rescheduled. this sometimes
resulted in the cycle detector being run concurrently in two
different scheduler threads which would cause a segfault or
assertion failure.

This commit fixes the logic issue so that the cycle detector will
only be recscheduled if it indicated that it needed to be
rescheduled to ensure that only a single copy of the cycle detector
will be running at a time as expected.
  • Loading branch information
dipinhora authored Feb 9, 2025
1 parent f8c6da9 commit e9cf333
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libponyrt/sched/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,9 @@ static pony_actor_t* steal(scheduler_t* sched)
if(next != NULL)
{
// If we have a next actor, push the cycle detector to the back
// of the queue
push(sched, actor);
// of the queue only if it needs to be rescheduled
if(reschedule)
push(sched, actor);
DTRACE2(ACTOR_DESCHEDULED, (uintptr_t)sched, (uintptr_t)actor);
actor = next;
}
Expand Down

0 comments on commit e9cf333

Please sign in to comment.