uncle-meat / open-hardware-monitor

Automatically exported from code.google.com/p/open-hardware-monitor
0 stars 0 forks source link

OverflowException in CPUID constructor #59

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version: 0.1.33.0

System.OverflowException: Arithmetic operation resulted in an overflow.
   at OpenHardwareMonitor.Hardware.CPU.CPUID..ctor(Int32 thread)
   at OpenHardwareMonitor.Hardware.CPU.CPUGroup.GetProcessorThreads()
   at OpenHardwareMonitor.Hardware.CPU.CPUGroup..ctor()
   at OpenHardwareMonitor.Hardware.Computer.Open()
   at OpenHardwareMonitor.GUI.MainForm..ctor()
   at OpenHardwareMonitor.Program.Main()

Common Language Runtime: 2.0.50727.3607
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 3
Process Type: 32-Bit

There are three sources of OverflowException in the CPUID constructor.

1) UIntPtr mask = (UIntPtr)(1L << thread); 
2) cpuidData = new uint[maxCpuid + 1, 4];
3) cpuidExtData = new uint[maxCpuidExt + 1, 4];

The case (1) does is not the reason for the stack trace above, because the
CPUID is never called with thread >= 32. But this should still be checked
in the constructor to avoid problems in the future.

For cases (2) and (3) an OverflowException can be thrown for example in
cases where maxCpuid + 1 = 0x80000000. This could happen if the eax = 0 in
"maxCpuidExt = eax - CPUID_EXT". So additional checks should be added to
the code for the calculation of maxCpuid and maxCpuidExt.

Original issue reported on code.google.com by moel.mich on 12 May 2010 at 11:41

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r141.

Original comment by moel.mich on 15 May 2010 at 10:38