diff options
author | Benoit Jacob <benoitjacob@google.com> | 2022-07-12 17:11:32 +0300 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-07-12 17:12:01 +0300 |
commit | fd42b25c4512913fd47a86826aecec7c9c3ee2b4 (patch) | |
tree | cb2770ced5b4670e22dc69d488662e0a0d8c8933 | |
parent | 841ea4172ba904fe3536789497f9565f2ef64129 (diff) |
Skip caches that have processor_count==0.
Some crash reports on Android tell of segfaults at address
(2^32 - 8) at the line below evaluating is_local,
which I guess would happen if processor_count==0.
PiperOrigin-RevId: 460454326
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | ruy/cpuinfo.cc | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 262d704..e085ed0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ option(RUY_FIND_CPUINFO "Use find_package to find cpuinfo" OFF) # Skip cpuinfo if it was already generated, which can happen when ruy is # a subdirectory in a wider project that already uses cpuinfo. -if (NOT TARGET cpuinfo::cpuinfo) +if (NOT TARGET cpuinfo AND NOT TARGET cpuinfo::cpuinfo) if (RUY_FIND_CPUINFO) find_package(cpuinfo REQUIRED) else() @@ -82,6 +82,10 @@ if (NOT TARGET cpuinfo::cpuinfo) endif() endif() +if (TARGET cpuinfo AND NOT TARGET cpuinfo::cpuinfo) + add_library(cpuinfo::cpuinfo ALIAS cpuinfo) +endif() + # googletest is only needed for tests. Projects embedding ruy as a subdirectory # and not needing to build ruy tests may proceed without a local checkout of # third_party/googletest. diff --git a/ruy/cpuinfo.cc b/ruy/cpuinfo.cc index a3e75d7..8a0e912 100644 --- a/ruy/cpuinfo.cc +++ b/ruy/cpuinfo.cc @@ -56,6 +56,9 @@ void QueryCacheParams(CpuCacheParams* cache_params) { continue; // continue, not break, it is possible to have L1+L3 but no // L2. } + if (!cache->processor_count) { + continue; // crashes from Chrome on Android suggests that might happen? + } const bool is_local = cpuinfo_get_processor(cache->processor_start)->core == cpuinfo_get_processor(cache->processor_start + |