https://bugzilla.novell.com/show_bug.cgi?id=324630

User [EMAIL PROTECTED] added comment
https://bugzilla.novell.com/show_bug.cgi?id=324630#c2


Marek Safar <[EMAIL PROTECTED]> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
                 CC|                                                |[EMAIL 
PROTECTED]
             Status|ASSIGNED                                        |NEEDINFO
      Info Provider|                                                |[EMAIL 
PROTECTED]




--- Comment #2 from Marek Safar <[EMAIL PROTECTED]>  2008-07-03 09:48:37 MDT ---
I spent some time looking into this issue and it seems to be a bug in MS
runtime.

gmcs emits fairly similar code, but we are using pointers (T*) whereas csc uses
references (T&) for array access. That's the only difference which I found.

The issue seems to either in 

public static unsafe BigInteger Reduce (BigInteger n, BigInteger m, uint
mPrime)
or
public static unsafe void SquarePositive (BigInteger bi, ref uint [] wkSpace)
or in both.

there is probably a race somewhere which twists one bit which later get
propagates due to way how is the value normalized.

following logging shows the problem:

bi.length <<= 1;

//////////////////////////////
if (bi.length != wkSpace.Length)
        Console.WriteLine (">> {0} {1} {2}", bi.length, wkSpace.Length, dl <<
1);
/////////////////////////////

// Normalize length
while (bi.length > 1 && tt [bi.length-1] == 0) bi.length--;


LOG RESULT

>> 50 48 50
>> 50 48 50
>> 52 48 52
>> 3720432480 -1772792230 56
System.AccessViolationException: Attempted to read or write protected memory.
Th
is is often an indication that other memory is corrupt.
   at Mono.Math.BigInteger.Kernel.SquarePositive(BigInteger bi, UInt32[]&
wkSpac
e)
   at Mono.Math.BigInteger.ModulusRing.OddPow(BigInteger b, BigInteger exp)
   at Foo.Calculator.Calculate()
System.NullReferenceException: Object reference not set to an instance of an
obj
ect.
   at Mono.Math.BigInteger.Normalize()
   at Mono.Math.BigInteger.BitCount()
   at Mono.Math.BigInteger.ModulusRing.OddPow(BigInteger b, BigInteger exp)
   at Foo.Calculator.Calculate()



The reason why I believe it's .NET issue is due to following workaround which
fixed the crash on .NET.


In method "public static unsafe BigInteger Reduce (BigInteger n, BigInteger m,
uint mPrime)" add

System.Threading.Thread.Sleep (0);

before very last line "return A;", this is very strange but it fixes the issue
for me.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to