-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Describe the issue
When initializing CPUIDInfo for ARM64 platform, the core count is retrieved and used to loop over and initialize the core_uarchs_ and is_armv8_narrow_ld_ member variables, however inside the loop the index is used to get the processor entry (not core) and the processor entry's linux_id is used as index into the two member variables. This can result in out of bound write.
Taking as example a machine with 8 cores and 12 processors, both vector would be sized for 8 values while the linux_id value can be 9, 10, 11, etc... (processor id). This can cause random crashes when using onnxruntime.
I believe there is no need to query the processor entry inside the loop and cpuinfo_get_core should be used directly.
onnxruntime/onnxruntime/core/common/cpuid_info.cc
Lines 161 to 180 in e0b66ca
| const uint32_t core_cnt = cpuinfo_get_cores_count(); | |
| core_uarchs_.resize(core_cnt, cpuinfo_uarch_unknown); | |
| is_armv8_narrow_ld_.resize(core_cnt, false); | |
| for (uint32_t c = 0; c < core_cnt; c++) { | |
| const struct cpuinfo_processor* proc = cpuinfo_get_processor(c); | |
| if (proc == nullptr) { | |
| continue; | |
| } | |
| const struct cpuinfo_core* corep = proc->core; | |
| if (corep == nullptr) { | |
| continue; | |
| } | |
| auto coreid = proc->linux_id; | |
| auto uarch = corep->uarch; | |
| core_uarchs_[coreid] = uarch; | |
| if (uarch == cpuinfo_uarch_cortex_a53 || uarch == cpuinfo_uarch_cortex_a55r0 || | |
| uarch == cpuinfo_uarch_cortex_a55) { | |
| is_armv8_narrow_ld_[coreid] = true; | |
| } | |
| } |
To reproduce
Compile ONNXRuntime 1.21.0 ARM64 for an Orin Jetson board (JetPack 6.2) and try running onnxruntime_perf_test (no argument needed). An invalid free crash happens at the end of execution.
Urgency
No response
Platform
Linux
OS Version
JetPack 6.2
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
1.21.0
ONNX Runtime API
C++
Architecture
ARM64
Execution Provider
Default CPU
Execution Provider Library Version
No response