sched_getcpu doesn't keep consistent with sysconf(_SC_NPROCESSORS_ONLN)
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.7k
- Forks
- 662
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 2
Description
When calling sysconf(_SC_NPROCESSORS_ONLN), the returned value is always 1. However when call sched_getcpu, the actual cpu number is returned, which may be larger than 1. It may lead to unexpected index out of range access in some program.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the discrepancy on Linux using the sysconf(_SC_NPROCESSORS_ONLN) and sched_getcpu entry points described in the issue. Trace where these values are used in rr and determine what behavior should prevent an inconsistent CPU count or resulting out-of-range access; done means the reported values and affected program behavior are consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100