Re: [Ikvm-developers] Java -> .NET using IKVM, x86 code works x64 doesn't
Brought to you by:
jfrijters
|
From: Jeroen F. <je...@su...> - 2011-10-19 10:05:14
|
Hi Nadim,
Thanks for the repro. As I suspected, it is indeed caused by an x64 JIT bug.
Here's a small C# repro:
class Program {
static void Dummy() { }
static void Method(int dummy1, int dummy2, int dummy3, int dummy4, int counter) {
for (int i = 0; i < 10; i++) {
try {
Dummy();
} catch {
}
System.Console.WriteLine(counter++);
}
}
public static void Main() {
Method(0, 0, 0, 0, 0);
}
}
It no longer repros in the .NET 4.5 developer preview and looking through connect I'm pretty sure this is the same bug:
https://connect.microsoft.com/VisualStudio/feedback/details/636466/variable-is-not-incrementing-in-c-release-x64#details
I could add another workaround to IKVM, but at this point I'd rather just advise people to stay away from the x64 JIT :-(
If you want a workaround for the specific problem you are seeing, you could build IKVM from source and tweak the mgf1 method in
openjdk7-b147\jdk\src\share\classes\sun\security\rsa\RSAPadding.java to avoid this pattern (e.g. copy the outOfs parameter into a local variable) or add an annotation to the method to disable JIT optimizations:
@cli.System.Runtime.CompilerServices.MethodImplAttribute.Annotation({ cli.System.Runtime.CompilerServices.MethodImplOptions.__Enum.NoOptimization })
Regards,
Jeroen
> -----Original Message-----
> From: Nadim Ratani [mailto:nr...@go...]
> Sent: Tuesday, October 18, 2011 19:40
> To: Jeroen Frijters
> Cc: ikv...@li...
> Subject: Re: [Ikvm-developers] Java -> .NET using IKVM, x86 code works
> x64 doesn't
>
> Here is a reduced test case. It works as expected in x86 (exits
> successfully) but gives the exception I mentioned in x64.
>
> 3 attachments in the zip:
> Program.cs (the test case)
> dsa (dsa key in keyczar format)
> rsa (rsa key in keyczar format)
>
> Regards,
>
> +n
> Nadim Ratani | Google Developer Relations | nr...@go... | Google
> Inc.
>
>
> On Mon, Oct 17, 2011 at 10:56 AM, Nadim Ratani <nr...@go...>
> wrote:
>
>
> Hi Jeroen,
>
> I am doing something a bit more complicated than the
> straightforward example in the KeyczarDotNet wiki. I am trying to
> reproduce this error in a smaller test case that I can share. FYI I am
> using:
> IKVM.NET Compiler version 0.46.0.1
>
> Thank you for the quick response.
>
>
> +n
> Nadim Ratani | Google Developer Relations | nr...@go... |
> Google Inc.
>
>
> On Sat, Oct 15, 2011 at 1:33 AM, Jeroen Frijters
> <je...@su...> wrote:
>
>
> Hi Nadim,
>
> That sample on the wiki works for me.
>
> I tried the following combinations:
> IKVM 0.46.0.1 .NET 2.0.50727.5448 x86
> IKVM 0.46.0.1 .NET 2.0.50727.5448 x64
> IKVM 0.46.0.1 .NET 4.0.30319.488 x86
> IKVM 0.46.0.1 .NET 4.0.30319.488 x64
> IKVM cvs head .NET 2.0.50727.5448 x86
> IKVM cvs head .NET 2.0.50727.5448 x64
> IKVM cvs head .NET 4.0.30319.488 x86
> IKVM cvs head .NET 4.0.30319.488 x64
>
> It could be a JIT bug. I have encounted many x64 JIT bugs and
> IKVM contains workarounds for a few of them.
>
> What exact versions (of IKVM and .NET) are you using? On what
> OS?
>
> Regards,
> Jeroen
>
> > -----Original Message-----
> > From: Nadim Ratani [mailto:nr...@go...]
> > Sent: Friday, October 14, 2011 23:55
> > To: ikv...@li...
> > Subject: [Ikvm-developers] Java -> .NET using IKVM, x86
> code works x64
> > doesn't
>
> >
> > I am using a library that uses javax.crypto to perform RSA
> decryption.
> > When I compile to a x86 DLL and use this library everything
> works fine.
> > When I switch to x64 (with no other changes that I am aware
> of) I get an
> > exception:
> > javax.crypto.BadPaddingException: lHash mismatch
> >
> > I am roughly following the instructions here to create a
> DLL:
> > http://code.google.com/p/keyczar/wiki/KeyczarDotNet
> >
> > And then using this DLL in a .NET project targeting x64.
> >
> > Does anyone have suggestions on where I can begin looking
> to get to the
> > bottom of this?
> >
> > +n
> > Nadim Ratani | Google Developer Relations |
> nr...@go... | Google
> > Inc.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|