Repository navigation
Conversation
1. PhysicalCpu::logicalCpu fallback path used m_MapCoreCpu[-1] (QMap operator[]), which silently inserts a default CoreCpu when key -1 is absent, polluting m_MapCoreCpu and causing coreNums() to return spurious -1 entries 2. Replace operator[] with find() in both coreCpu(int id) and logicalCpu(int id); when key is not found, return a static default instance reference instead of inserting into the map 3. No API signature changes; only internal access pattern changed to eliminate implicit insertion side effects Log: Fix CPU topology data corruption caused by operator[] silent insert Influence: 1. Verify CPU topology information displays correctly with no spurious entries 2. Test coreCpu() and logicalCpu() with both existing and non-existing IDs to confirm no data pollution 3. Verify coreNums() returns correct key list without -1 entries fix: 避免 QMap operator[] 隐式插入污染 coreNums 数据 1. PhysicalCpu::logicalCpu 的 fallback 路径使用 m_MapCoreCpu[-1](QMap operator[]),当 key -1 不存在时隐式插入默认 CoreCpu,污染 m_MapCoreCpu 数据,导致 coreNums() 返回含虚假 -1 条目 2. 将 coreCpu(int id) 和 logicalCpu(int id) 中的 operator[] 替换为 find(),key 不存在时返回静态默认实例引用,不再隐式插入 3. 不改 API 签名,仅修改内部访问方式,消除隐式插入副作用 Log: 修复 operator[] 隐式插入导致 CPU 拓扑数据错误 Influence: 1. 验证 CPU 拓扑信息显示正确,无虚假条目 2. 测试 coreCpu() 和 logicalCpu() 传入存在和不存在的 ID,确认无数据污染 3. 验证 coreNums() 返回的键列表不含 -1 条目 PMS: BUG-2
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR prevents CPU topology corruption caused by QMap::operator[] inserting missing keys, especially the fallback -1 core. Both lookup methods now use non-mutating find() access and static default references, so querying missing IDs no longer pollutes coreNums() while retaining the existing API. Sequence diagram for non-mutating CPU lookupsequenceDiagram
participant Caller
participant PhysicalCpu
participant CoreMap as m_MapCoreCpu
participant Default as StaticDefault
Caller->>PhysicalCpu: coreCpu(id)
PhysicalCpu->>CoreMap: find(id)
alt key exists
CoreMap-->>PhysicalCpu: CoreCpu reference
PhysicalCpu-->>Caller: CoreCpu reference
else key missing
PhysicalCpu->>Default: return s_invalidCoreCpu
Default-->>Caller: CoreCpu reference
end
Caller->>PhysicalCpu: logicalCpu(id)
PhysicalCpu->>CoreMap: find(-1)
alt fallback key exists
CoreMap-->>PhysicalCpu: CoreCpu reference
PhysicalCpu->>CoreMap: logicalCpu(-1)
CoreMap-->>Caller: LogicalCpu reference
else fallback key missing
PhysicalCpu->>Default: return s_invalidLogicalCpu
Default-->>Caller: LogicalCpu reference
end
Flow diagram for preserving coreNums during missing-ID lookupflowchart LR
A[Lookup missing CPU ID] --> B[QMap::find]
B --> C{Key exists?}
C -->|Yes| D[Return mapped CPU reference]
C -->|No| E[Return static default reference]
D --> F[Map remains unchanged]
E --> F
F --> G[coreNums returns only real keys]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: prevent QMap operator[] silent insert polluting coreNums
operator[]), which silently inserts a default CoreCpu when key -1
is absent, polluting m_MapCoreCpu and causing coreNums() to return
spurious -1 entries
logicalCpu(int id); when key is not found, return a static default
instance reference instead of inserting into the map
eliminate implicit insertion side effects
Log: Fix CPU topology data corruption caused by operator[] silent insert
Influence:
entries
IDs to confirm no data pollution
fix: 避免 QMap operator[] 隐式插入污染 coreNums 数据
operator[]),当 key -1 不存在时隐式插入默认 CoreCpu,污染
m_MapCoreCpu 数据,导致 coreNums() 返回含虚假 -1 条目
find(),key 不存在时返回静态默认实例引用,不再隐式插入
Log: 修复 operator[] 隐式插入导致 CPU 拓扑数据错误
Influence:
PMS: BUG-2
Summary by Sourcery
Prevent CPU topology map pollution from missing core and logical CPU lookups.
Bug Fixes:
Enhancements: