Skip to content

Conversation

@wamuir
Copy link

@wamuir wamuir commented Oct 26, 2021

list_cpu_features segfaults in at least some cases after 641e24e. I am experiencing on Linux (Comet Lake) and FreeBSD (Kaby Lake). PR resolves by limiting parsing in AddCacheInfo to the range of possible cache levels.

@gchatelet
Copy link
Collaborator

Thx for the PR, I spotted it this morning as well.
Can you simply change the for loop as follows (it will prevent unpleasant merging on my side)

  for (int cache_id = 0; cache_id < CPU_FEATURES_MAX_CACHE_LEVEL &&
                         info->size < CPU_FEATURES_MAX_CACHE_LEVEL;
       cache_id++) {

It's still not a proper fix but at least it will fix the corruption.

@gchatelet
Copy link
Collaborator

Ha my bad I misread your patch.
The problem is not in list_cpu_features.c but in cpuinfo_x86.c.

I'll send a fix ASAP

@gchatelet gchatelet closed this Oct 26, 2021
@wamuir
Copy link
Author

wamuir commented Oct 26, 2021

Awesome, thanks!

gchatelet added a commit that referenced this pull request Oct 26, 2021
@gchatelet gchatelet self-assigned this Oct 26, 2021
@gchatelet gchatelet added the bug Something isn't working label Oct 26, 2021
@gchatelet
Copy link
Collaborator

The memory corruption is fixed but cache info might be duplicated (read from Leaf2 and Leaf 4/0x8000001D).
I'll prepare a proper fix ASAP.

gchatelet added a commit that referenced this pull request Oct 26, 2021
@gchatelet gchatelet added this to the v0.7.0 milestone Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants