Skip to content

Commit 02ba122

Browse files
authored
fix: Fix division by zero in physicalCores on intel (#162)
1 parent 9258d0f commit 02ba122

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cpuid.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,12 @@ func physicalCores() int {
881881
v, _ := vendorID()
882882
switch v {
883883
case Intel:
884-
return logicalCores() / threadsPerCore()
884+
lc := logicalCores()
885+
tpc := threadsPerCore()
886+
if lc > 0 && tpc > 0 {
887+
return lc / tpc
888+
}
889+
return 0
885890
case AMD, Hygon:
886891
lc := logicalCores()
887892
tpc := threadsPerCore()

0 commit comments

Comments
 (0)