Skip to content

Fix NULL dereference in ARM64 getarch when CPUs are offline - #6190

Merged
martin-frbg merged 1 commit into
OpenMathLib:developfrom
FischLu:fix/arm64-getarch-offline-cpus
Oct 29, 2026
Merged

martin-frbg merged 1 commit into
OpenMathLib:developfrom
FischLu:fix/arm64-getarch-offline-cpus

Conversation

@FischLu

@FischLu FischLu commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix a NULL pointer dereference in ARM64 getarch when some CPUs are offline, such as on NVIDIA Jetson devices in low-power modes.

Root cause

detect() reads the CPU count from /sys/devices/system/cpu/possible, but falls back to /proc/cpuinfo, which only lists online CPUs.

When possible > online, the fallback loop can reach EOF and call strstr() with a NULL cpu_implementer, causing SIGSEGV.

Reproduction

NVIDIA Jetson AGX Orin, 30W power mode:

Possible CPUs: 12 (0-11)
Online CPUs:    8 (0-7)
Offline CPUs:   4 (8-11)

getarch 0 → SIGSEGV (exit 139)
getarch 1 → SIGSEGV (exit 139)

GDB confirms the crash in cpuid_arm64.c due to strstr(NULL, "0x41").

This also causes downstream CMake configuration and compilation errors.

Fix

Stop the /proc/cpuinfo fallback loop when the required fields are missing:

if (cpu_implementer == NULL || cpu_part == NULL) {
    break;
}

Only 3 lines added. Existing CPU-count behavior remains unchanged.

Testing

  • Before fix: SIGSEGV reproduced on Jetson AGX Orin.
  • Unaffected host: Jetson AGX Thor (14 CPUs online) works normally.
  • After fix: Not independently tested on ARM64.

The issue also affects v0.3.29 and v0.3.33. A backport may be appropriate.

@martin-frbg martin-frbg added this to the 0.3.35 milestone Oct 28, 2026
@martin-frbg

Copy link
Copy Markdown
Collaborator

Thank you - interesting trap I set for myself there.
(Alpine CI failure can be ignored - they closed down access to their repository while addressing urgent bugs)

@martin-frbg
martin-frbg merged commit 06608a6 into OpenMathLib:develop Oct 29, 2026
108 of 110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants