You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FFM CPU temperature on Apple Silicon is nondeterministic and diverges from JNA #3529
The JNA provider is stable and plausible on the same machine at the same moment:
oshi.SystemInfo 59.12498092651367
So the FFM path intermittently reports ~6.7 °C where JNA reports ~59 °C. It is not thermal variation — 6.7 is bit-for-bit identical every time it appears, and it alternates run to run rather than drifting.
Reproduction
Verified the flake is pre-existing by stashing the #3528 changes, rebuilding oshi-core-ffm from master, and re-running: master produced 6.699999809265137 on three consecutive runs and 57.995201110839844 on another. The #3528 branch produced both values too. Both branches show both values, so the variable is not the code under change.
Suspected cause
SmcUtilFFM.smcGetFirstFloat(conn, SMC_KEYS_CPU_TEMP_AS) returns the first key whose value is > 0, scanning Tp09, Tp0T, Tp01, Tp05, Tp0D. A key that intermittently yields a small bogus reading would be accepted and short-circuit the scan, which matches the exactly-repeating 6.7. Worth checking whether the SMC key-info cache (KEY_INFO_CACHE) is being populated with a stale or wrong dataSize/dataType on some open, since that would change how the same bytes are decoded.
A useful first diagnostic would be logging each key's raw bytes, dataSize and dataType per read and diffing a 6.7 run against a 59 run.
Scope
Apple Silicon path only. Not investigated on Intel Macs, and the non-_AS key (TC0P) was not exercised here.
Investigated on the M2 Max. The premise of this issue is wrong — there is no FFM/JNA divergence, and no nondeterminism. Correcting the record, and re-scoping to the real bug underneath.
There is no divergence
Reading the raw SMC payload from both implementations at the same moment gives byte-identical results:
66 66 d6 40 little-endian is exactly 6.7f. Interleaving the two implementations over repeated samples gave 0 disagreements in 12 rounds, and 7/7 agreement across a load transition. Both decode correctly; both see the same bytes.
What is actually happening
The value tracks CPU cluster activity, deterministically and reversibly:
When the P-cores are idle, the SMC parks these sensors and returns a fixed sentinel — 6.700 for Tp09/Tp01 and 4.633 for Tp05/Tp0D. Two telltales that these are not readings:
In the parked state the sensors are pairwise exactly equal. Under load they differ (52.630 / 53.113 / 50.482 / 51.162), as independent sensors should.
6.7 °C is below room ambient, so it cannot be a die temperature.
Sustained load brings them live within ~1.6 s; they park again within ~1.5 s of the load stopping. What looked like run-to-run flakiness was just whether the machine happened to be busy.
The real bug
smcGetFirstFloat accepts any value > 0, so it returns the parked 6.700 as the CPU temperature whenever the machine is idle — which is most of the time. Both implementations share this, since the logic is duplicated in SmcUtil and SmcUtilFFM, so any fix belongs in both twins (and likely the GPU path, which uses the same helper).
Sensors#getCpuTemperature documents 0 or NaN as "unavailable", so rejecting an implausible reading and returning 0 is contractually clean.
Rejecting on a plausibility floor is more robust than matching the sentinel values, which are probably model-specific — I have only verified 6.700/4.633 on one M2 Max. A die below ~10 °C is not physical in any room someone is running a machine in, and idle Apple Silicon normally sits around 25-40 °C, so a floor in that gap discards the sentinel without ever rejecting a genuine reading.
Retitling suggestion: "Apple Silicon idle CPU/GPU temperature reports an implausible parked sensor value".
One more observation that firms up the diagnosis: the parked values split along cluster lines, not randomly.
Tp09 = Tp01 = 6.700 <- both P-core sensors on M2
Tp05 = Tp0D = 4.633 <- both E-core sensors on M2
Within a cluster the readings are bit-identical; under load the same sensors diverge (52.630 / 53.113 / 50.482 / 51.162). One gated cluster reporting a single floor explains that; uninitialized memory or independent sensors would not produce two exact pairs that split on the P/E boundary.
Two notes for whoever writes the fix, both pointing the same way:
Per exelban/stats#1703 the SMC firmware is inconsistent between devices even when they share an SoC, so 6.700/4.633 are likely specific to this M2 Max. Matching sentinel values would not travel.
Per exelban/stats#1012 the same key changes meaning across generations — Tp05 is a P-core on M1 Pro/Max but an E-core on M2 — so per-key special-casing would rot. Validity has to be judged from the value.
Activity
dbwiddis commentedon Jul 26, 2026
Investigated on the M2 Max. The premise of this issue is wrong — there is no FFM/JNA divergence, and no nondeterminism. Correcting the record, and re-scoping to the real bug underneath.
There is no divergence
Reading the raw SMC payload from both implementations at the same moment gives byte-identical results:
66 66 d6 40little-endian is exactly6.7f. Interleaving the two implementations over repeated samples gave 0 disagreements in 12 rounds, and 7/7 agreement across a load transition. Both decode correctly; both see the same bytes.What is actually happening
The value tracks CPU cluster activity, deterministically and reversibly:
When the P-cores are idle, the SMC parks these sensors and returns a fixed sentinel —
6.700forTp09/Tp01and4.633forTp05/Tp0D. Two telltales that these are not readings:Sustained load brings them live within ~1.6 s; they park again within ~1.5 s of the load stopping. What looked like run-to-run flakiness was just whether the machine happened to be busy.
The real bug
smcGetFirstFloataccepts any value> 0, so it returns the parked6.700as the CPU temperature whenever the machine is idle — which is most of the time. Both implementations share this, since the logic is duplicated inSmcUtilandSmcUtilFFM, so any fix belongs in both twins (and likely the GPU path, which uses the same helper).Sensors#getCpuTemperaturedocuments0orNaNas "unavailable", so rejecting an implausible reading and returning 0 is contractually clean.Rejecting on a plausibility floor is more robust than matching the sentinel values, which are probably model-specific — I have only verified
6.700/4.633on one M2 Max. A die below ~10 °C is not physical in any room someone is running a machine in, and idle Apple Silicon normally sits around 25-40 °C, so a floor in that gap discards the sentinel without ever rejecting a genuine reading.Retitling suggestion: "Apple Silicon idle CPU/GPU temperature reports an implausible parked sensor value".
dbwiddis commentedon Jul 27, 2026
One more observation that firms up the diagnosis: the parked values split along cluster lines, not randomly.
Within a cluster the readings are bit-identical; under load the same sensors diverge (52.630 / 53.113 / 50.482 / 51.162). One gated cluster reporting a single floor explains that; uninitialized memory or independent sensors would not produce two exact pairs that split on the P/E boundary.
Two notes for whoever writes the fix, both pointing the same way:
6.700/4.633are likely specific to this M2 Max. Matching sentinel values would not travel.Tp05is a P-core on M1 Pro/Max but an E-core on M2 — so per-key special-casing would rot. Validity has to be judged from the value.Reject implausible Apple Silicon SMC temperatures (#3531)