Skip to content

lifecycle: Add exception handling for CPU affinity#113

Open
SangKyeong-Jeong wants to merge 3 commits intoeclipse-score:mainfrom
SangKyeong-Jeong:lifecycle/bugfix/affinity-exception-handling
Open

lifecycle: Add exception handling for CPU affinity#113
SangKyeong-Jeong wants to merge 3 commits intoeclipse-score:mainfrom
SangKyeong-Jeong:lifecycle/bugfix/affinity-exception-handling

Conversation

@SangKyeong-Jeong
Copy link
Contributor

When there are 32 CPU cores, an issue arises where the process cannot be executed, and when there are more than 32 cores, a problem occurs where fewer cores than expected are used. To resolve this issue, exception handling is added to set the maximum number of cores using the uint32_t type when there are more than 32 cores.

@github-actions
Copy link

github-actions bot commented Mar 11, 2026

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.4.2) and connecting to it...
INFO: Invocation ID: df601b78-96c1-47f6-abb3-0ff156e34551
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'score_rust_policies', the root module requires module version score_rust_policies@0.0.3, but got score_rust_policies@0.0.5 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //:license-check (68 packages loaded, 9 targets configured)

Analyzing: target //:license-check (89 packages loaded, 9 targets configured)

Analyzing: target //:license-check (145 packages loaded, 2400 targets configured)

Analyzing: target //:license-check (153 packages loaded, 5233 targets configured)

Analyzing: target //:license-check (154 packages loaded, 5922 targets configured)

Analyzing: target //:license-check (165 packages loaded, 7901 targets configured)

Analyzing: target //:license-check (165 packages loaded, 7901 targets configured)

Analyzing: target //:license-check (165 packages loaded, 7901 targets configured)

Analyzing: target //:license-check (168 packages loaded, 9789 targets configured)

Analyzing: target //:license-check (169 packages loaded, 9913 targets configured)

Analyzing: target //:license-check (169 packages loaded, 9913 targets configured)

INFO: Analyzed target //:license-check (170 packages loaded, 10039 targets configured).
[13 / 16] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 0s disk-cache, processwrapper-sandbox
[14 / 16] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 27.411s, Critical Path: 2.67s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@github-actions
Copy link

The created documentation from the pull request is available at: docu-html

@FScholPer
Copy link
Contributor

@SangKyeong-Jeong whats the status here can we review it

Copy link
Contributor

@FScholPer FScholPer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please check also the OS Abstraction Layer

@daeyoung-jeong-lge
Copy link

@FScholPer We will double-check the OSAL implementation files (specifically under src/internal/osal/linux and qnx) to ensure the CPU core limit is handled consistently across different platforms. We'll update the PR if any adjustments are needed.
And when we are ready, is it OK for us to change the status of this issue to "Ready for review"?

@SangKyeong-Jeong
Copy link
Contributor Author

@FScholPer

This issue is unrelated to the OSAL.

When the CPU core count is 32, the return value of the ConfigurationManager::kDefaultProcessorAffinityMask() function is 0, causing an error when setting the CPU affinity to 0.

Shifting a 32-bit integer by 32 bits results in a shift-count-overflow error, which leads to undefined behavior. Consequently, the return value of ConfigurationManager::kDefaultProcessorAffinityMask() becomes 0, causing this issue.

@SangKyeong-Jeong SangKyeong-Jeong marked this pull request as ready for review March 12, 2026 01:02
@daeyoung-jeong-lge
Copy link

@FScholPer
As SangKyeong said, regarding to OSAL, this issue is not related. If we find some issue on OSAL, we will handle it as the separated issue and PR.

Please review this. Thanks.

Shifting a 32-bit number by 32 bits causes undefined behavior,
so modify it to perform the shift operation on a 64-bit number
and then cast it.
@daeyoung-jeong-lge
Copy link

We encounter the Formatting checks fail. It looks like the temporal download connection problem, so I want to re-run the batch, but maybe don't have a permission to do.

Copy link
Contributor

@pawelrutkaq pawelrutkaq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase branch

const uint32_t ConfigurationManager::kDefaultProcessExecutionError = 1U;
uint32_t ConfigurationManager::kDefaultProcessorAffinityMask() {
return (1U << osal::getNumCores()) - 1U;
return static_cast<uint32_t>((1ULL << osal::getNumCores()) - 1ULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When there are 64 cores, is there still the issue or ? ;) In general, this affinity in LM supports only up to 32 cores, since later on cpu_mask_ also does not support more. So either we do an assert is there is more than 32 cores, or we do wanirng logs that default affinity is set only to first 32 cores ;)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if there are 64 cores, this issue does not reproduce. Inside the osal::getNumCores() function, there is exception handling, and the maximum value this function can return is 32. Therefore, a similar problem does not occur on a 64-core system.

If this issue is not fixed, CPU affinity cannot be configured in a 32-core system, which causes the lifecycle to not operate correctly. I have explained this in the PR.

Copy link

@daeyoung-jeong-lge daeyoung-jeong-lge Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR addresses the Undefined Behavior on 32-core systems. As chungsky mentioned, getNumCores() already caps the count at 32, so >32 core systems are safe with this default.

@SangKyeong-Jeong
Copy link
Contributor Author

Done rebasing

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.

5 participants