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

pthread_detach after pthread_setaffinity_np #8852

Merged
merged 5 commits into from Nov 6, 2023

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
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
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
97 of 98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant