Bug: Platform architecture does not report bitness correctly

7 posts, 0 answers
  1. Tom
    Tom avatar
    3 posts
    Member since:
    Nov 2011

    Posted 20 Feb 2012 Link to this post

    Hello,

    Platform architecture reports x86 even when its running in 64bit (compiled with VS for anyCPU and running on a 64bit machine)

    I confirmed this with taks manager and should be easy to reproduce

    Kind Regards, Tom
  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 22 Feb 2012 Link to this post

    Hello Tom,

    Building application with an "Any CPU" platform target specified doesn't necessary mean that it is x64. First and foremost this is only determined after the JIT compilation when dll is loaded into the application domain. 

    Regards,
    Kaloyan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Tom
    Tom avatar
    3 posts
    Member since:
    Nov 2011

    Posted 22 Feb 2012 Link to this post

    Hi,

    I understand that but I did not explain myself well. If you compile to x86 or anyCPU the only difference is that a flag is set in the header of the assembly. A 64bit runtime will switch to WOW64 (32bit compat mode) if this flag is set as x86.

    What I then expect ist hat if I compile to AnyCPU that JustDecompile would give this information. If I tested at work correctly (I cannot access it currently) it will show up as x86 while I expect AnyCPU.

    Kind Regards, Tom
  5. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 23 Feb 2012 Link to this post

    Hi Tom,

    You are absolutely right. What is interesting here is that according to the IL Dasm tool an assembly build on Any CPU and x86 has an exactly the same Machine value == 0x014c in COFF header. Just like you, we are more than interested to catch the difference in those cases, so we will investigate it deeper. Any related info will be more then appreciated.

    Kind regards,
    Kaloyan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. Chris
    Chris avatar
    12 posts
    Member since:
    May 2011

    Posted 03 Mar 2012 Link to this post

    Hi,

    Hopefully I can be of some help with the bitness, as you have seen the machine flag for Any CPU and x86 are the same, the difference is in the CLR Header. If you use DumpBin to inspect the header you will see that the CLR Header flags for Any CPU will have the IL Only flag set, while a x86 will have the "32-Bit Required" flag set as well.

    dumpbin /clrheader CPUTargetTest.exe

    ANY CPU:
     clr Header:

                  48 cb
                2.05 runtime version
                205C [     604] RVA [size] of MetaData Directory
                   1 flags
                       IL Only

    x86:

      clr Header:

                  48 cb
                2.05 runtime version
                205C [     604] RVA [size] of MetaData Directory
                   3 flags
                       IL Only
                       32-Bit Required


    You can also check this with corflags.exe

    corflags CPUTargetsTest.exe

    ANY CPU:
    Version   : v4.0.30319
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 1
    ILONLY    : 1
    32BIT     : 0
    Signed    : 0

    x86:
    Version   : v4.0.30319
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 3
    ILONLY    : 1
    32BIT     : 1
    Signed    : 0

    Best Regards,

    Chris
  7. Tom
    Tom avatar
    3 posts
    Member since:
    Nov 2011

    Posted 05 Mar 2012 Link to this post

    Hi Chris,

    Good analysis. That's what I was about to post once I had the time

    Kind Regards, Tom
  8. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 06 Mar 2012 Link to this post

    Hi Chris,

    That is exactly what we came up with when discussing the problem. It is included in the latest internal build so give it a try and please let us know if any problem pops up. 

    Kind regards,
    Kaloyan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
DevCraft banner