Skip to content

Commit

Permalink
clear sched->lock_onwer at fork
Browse files Browse the repository at this point in the history
`sched->lock_owner` can be non-NULL at fork because the timer thread
can acquire the lock while forking. `lock_owner` information is for
debugging, so we only need to clear it at fork.

I hope this patch fixes the following assertion failure:
```
thread_pthread.c:354:thread_sched_lock_:sched->lock_owner == NULL
```
  • Loading branch information
ko1 committed Dec 18, 2023
1 parent f35fec7 commit d44f4e0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions thread_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,11 @@ void
rb_thread_sched_init(struct rb_thread_sched *sched, bool atfork)
{
rb_native_mutex_initialize(&sched->lock_);

#if VM_CHECK_MODE
sched->lock_owner = NULL;
#endif

ccan_list_head_init(&sched->readyq);
sched->readyq_cnt = 0;

Expand Down

0 comments on commit d44f4e0

Please sign in to comment.