This project is read-only.
1
Vote

Arithmetic overflow exception on 64bit systems

description

On 64bit systems the hash calculation method in MemoKey.cs often throws an arithmetic overflow exception.
The issue lies here:
        var m = Marshal.GetFunctionPointerForDelegate(method).ToInt32();
Converting a pointer to int32 on a 64 bit machine throws.
        var m = (int)Marshal.GetFunctionPointerForDelegate(method).ToInt64();
will work.

I currently use:
        var m = Marshal.GetFunctionPointerForDelegate(method).ToInt64();
        var p = position.GetHashCode();
        this.hash = (int)m ^ p;
I did not check how well this works regarding hash collisions and did not check in the fix thus.

Best regards,

Simon

comments

justinc wrote Feb 19, 2014 at 11:17 PM

Interesting, ok thanks.