From 857bcab0f762b86a03109f98599908c985770ace Mon Sep 17 00:00:00 2001 From: Ruy Contributors Date: Wed, 22 Jul 2026 04:04:54 -0700 Subject: [PATCH] Add nullptr check for processor in QueryCacheParams. When calling cpuinfo_get_processor(i), it can return nullptr on certain Android devices (e.g. Xiaomi, Oppo). When processor is null, accessing processor->cache causes a fatal SIGSEGV during ruy::CpuInfo::Initialize(). This change adds a null guard for processor in QueryCacheParams to ensure it is skipped, allowing safe fallback to default cache parameters if detection fails. PiperOrigin-RevId: 952022058 --- ruy/cpuinfo.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ruy/cpuinfo.cc b/ruy/cpuinfo.cc index 5daee0b7f1..ccad777bea 100644 --- a/ruy/cpuinfo.cc +++ b/ruy/cpuinfo.cc @@ -48,6 +48,9 @@ bool QueryCacheParams(CpuCacheParams* cache_params) { int local_cache_size = 0; int last_level_cache_size = 0; const cpuinfo_processor* processor = cpuinfo_get_processor(i); + if (!processor) { + continue; + } // Loop over cache levels. Ignoring L4 for now: it seems that in CPUs that // have L4, we would still prefer to stay in lower-latency L3. for (const cpuinfo_cache* cache :