Crash Seen with unspecified micro arch for Windows On Arm devices when getting the cpu micro arch info to check the core type
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1.2k
- Forks
- 409
- PR merge metrics
- No merged PRs in 30d
Description
For WOA(windows on ARM) devices where the CPU string does not match any string in woa_chips, cpuinfo_get_uarch returns NULL (index = 0 and cpuinfo_uarchs_count = 0 for unspecified CPU).
const struct cpuinfo_uarch_info* cpuinfo_get_uarch(uint32_t index) {
if (!cpuinfo_is_initialized) {
cpuinfo_log_fatal("cpuinfo_get_%s called before cpuinfo is initialized", "uarch");
}
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 || CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
if CPUINFO_UNLIKELY (index >= cpuinfo_uarchs_count) {
return NULL;
}
return &cpuinfo_uarchs[index];
#else
if CPUINFO_UNLIKELY (index != 0) {
return NULL;
}
return &cpuinfo_global_uarch;
#endif
To gracefully handle return of cpuinfo_uarch_info below are the 2 methods can be used
- Return a dummy cpuinfo_uarch_info struct with uarch = cpuinfo_uarch_unknown (0) instead of NULL.
- As part of usage guidelines for cpuinfo_get_uarch, Include NULL checking for return value
// check for ARM cortex a-53 CPU
cpuinfo_uarch_info *cpu_data = cpuinfo_get_uarch(cpuinfo_get_current_uarch_index())
if( cpu_data!= NULL)
{
switch (cpu_data->uarch){
case cpuinfo_uarch_cortex_a53:
case cpuinfo_uarch_cortex_a55r0:
case cpuinfo_uarch_cortex_a55:
return true;
default:
return false;
}
return false
This would help stability of libraries/binaries using cpuinfo on devices with unknown micro arch for Windows on ARM devices .
Also I would assume the same issue would be seen for other platforms as well.
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 in src/arm/windows/init.c and inspect how an unmatched Windows on ARM CPU leaves cpuinfo_uarchs_count at zero, then trace callers of cpuinfo_get_uarch and cpuinfo_get_current_uarch_index. Decide between returning an unknown uarch entry and requiring callers to handle NULL; done means unknown microarchitectures no longer cause instability and the chosen behavior is clear for users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100