Skip to content

Conversation

@mame
Copy link
Member

@mame mame commented Nov 6, 2023

After a pthread for getaddrinfo is detached, we cannot predict when the thread will exit. It would lead to a segfault by setting pthread_setaffinity to the terminated pthread. I guess this problem would be more likely to occur in high-load environments.

https://bugs.ruby-lang.org/issues/19965#note-4
https://bugs.ruby-lang.org/issues/19965#note-7

This change detaches the pthread after pthread_setaffinity is called.

@mame mame force-pushed the pthread_detach-after-pthread_setaffinity_np branch 2 times, most recently from 0ff1798 to f5779a4 Compare November 6, 2023 18:46
@mame mame marked this pull request as ready for review November 6, 2023 18:46
mame added 3 commits November 7, 2023 03:47
After a pthread for getaddrinfo is detached, we cannot predict when the
thread will exit. It would lead to a segfault by setting
pthread_setaffinity to the terminated pthread.  I guess this problem
would be more likely to occur in high-load environments.

This change detaches the pthread after pthread_setaffinity is called.
[Feature #19965]
@mame mame force-pushed the pthread_detach-after-pthread_setaffinity_np branch from f5779a4 to c4aaaaf Compare November 6, 2023 18:47
@mame mame enabled auto-merge (rebase) November 6, 2023 18:47
mame added 2 commits November 7, 2023 04:08
Do not use `pthread_attr_setaffinity_np` if `sched_getcpu()` exceeds
`CPU_SETSIZE`. (Using `CPU_ALLOC()` would be more appropriate.)
@mame mame merged commit 49b6dc8 into ruby:master Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant