Testing mixed mode x86 assemblies throw BadImageFormatException

190 views
Skip to first unread message

Rob Prouse

unread,
Aug 12, 2010, 9:10:59 AM8/12/10
to galli...@googlegroups.com

I have entered an issue & patch for this, but I wanted to bring it to the devs’ attention because I was hoping to get the fix in for 3.2 as it has been blocking some of our testing.

 

http://code.google.com/p/mb-unit/issues/detail?id=704

 

The problem is that when running on a 64bit OS, attempting to load/run a mixed mode x86 assembly (all C++ test assemblies compiled x86) causes the host to crash with a BadImageFormatException. This happens because the runner misidentifies the assembly and incorrectly launches the AnyCPU host instead of the x86.

 

It is misidentified because mixed mode assemblies don’t set the 32BIT corflags in the header, instead you need to look at a combination of the PE and ILONLY flags. More information is in the issue and at http://blogs.msdn.com/b/slessard/archive/2010/04/09/types-of-managed-code-assemblies.aspx

 

The fix turned out to be pretty easy, It was just a one line change to AssemblyMetadata to take into account the additional flags. The patch and a test solution is attached to the issue. I have tested the fix on a 64bit OS with C# and C++ test suites compiled x86 and x64.

 

Any chance of getting this fix in for the release?

 

Thanks

 

Rob Prouse

image001.gif

Graham Hay

unread,
Aug 12, 2010, 9:18:59 AM8/12/10
to galli...@googlegroups.com
Yes, in a word. I'll try and get it done tonight. Thanks Rob, that's my sort of issue :)

--
You received this message because you are subscribed to the Google Groups "gallio-dev" group.
To post to this group, send email to galli...@googlegroups.com.
To unsubscribe from this group, send email to gallio-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gallio-dev?hl=en.

image001.gif

Yann Trevin

unread,
Aug 12, 2010, 9:53:00 AM8/12/10
to galli...@googlegroups.com
How nice! A nifty patch!
Thanks a lot, Rob!

:)

2010/8/12 Graham Hay <graha...@gmail.com>
image001.gif

Rob Prouse

unread,
Aug 11, 2010, 3:45:04 PM8/11/10
to galli...@googlegroups.com

I have entered an issue & patch for this, but I wanted to bring it to the devs’ attention because I was hoping to get the fix in for 3.2 as it has been blocking some of our testing.

 

http://code.google.com/p/mb-unit/issues/detail?id=704

 

The problem is that when running on a 64bit OS, attempting to load/run a mixed mode x86 assembly (all C++ test assemblies compiled x86) causes the host to crash with a BadImageFormatException. This happens because the runner mis-identifies the assembly and incorrectly launches the AnyCPU host instead of the x86.

 

It is mis-identified because mixed mode assemblies don’t set the 32BIT corflags in the header, instead you need to look at a combination of the PE and ILONLY flags. More information is in the issue and at http://blogs.msdn.com/b/slessard/archive/2010/04/09/types-of-managed-code-assemblies.aspx

image001.gif

Graham Hay

unread,
Aug 13, 2010, 5:40:36 AM8/13/10
to gallio-dev
Is there an echo in here? :)

On Aug 11, 8:45 pm, "Rob Prouse" <r...@prouse.org> wrote:
> I have entered an issue & patch for this, but I wanted to bring it to the
> devs' attention because I was hoping to get the fix in for 3.2 as it has
> been blocking some of our testing.
>
> http://code.google.com/p/mb-unit/issues/detail?id=704
>
> The problem is that when running on a 64bit OS, attempting to load/run a
> mixed mode x86 assembly (all C++ test assemblies compiled x86) causes the
> host to crash with a BadImageFormatException. This happens because the
> runner mis-identifies the assembly and incorrectly launches the AnyCPU host
> instead of the x86.
>
> It is mis-identified because mixed mode assemblies don't set the 32BIT
> corflags in the header, instead you need to look at a combination of the PE
> and ILONLY flags. More information is in the issue and athttp://blogs.msdn.com/b/slessard/archive/2010/04/09/types-of-managed-...
> semblies.aspx
>
> The fix turned out to be pretty easy, It was just a one line change to
> AssemblyMetadata to take into account the additional flags. The patch and a
> test solution is attached to the issue. I have tested the fix on a 64bit OS
> with C# and C++ test suites compiled x86 and x64.
>
> Any chance of getting this fix in for the release?
>
> Thanks
>
> Rob Prouse
>
>  image001.gif
> < 1KViewDownload

Graham Hay

unread,
Aug 13, 2010, 9:22:59 AM8/13/10
to galli...@googlegroups.com
Patched, thanks Rob.
image001.gif

Rob Prouse

unread,
Aug 13, 2010, 3:16:30 PM8/13/10
to galli...@googlegroups.com
Sorry for the dupe, I had originally sent from an email address that is not
subscribed. The email didn't show up after a few hours, so I resent. I guess
the original eventually made its way through ;)

Yann Trevin

unread,
Aug 13, 2010, 3:18:40 PM8/13/10
to galli...@googlegroups.com
ECHO....ECHO... Echo.... echo... 

:D

2010/8/13 Rob Prouse <rpr...@gmail.com>

Vivek Bhatia

unread,
Jul 6, 2012, 9:55:43 PM7/6/12
to galli...@googlegroups.com
Does this issue persist? In Visual C# Express 2010, I've been getting a BadImageFormatException whenever my "MyCoolProject.Tests" project tries to access anything from my "MyCoolProject" project. It didn't seem to matter which platform I had compiled my two projects with either - Any CPU, x86 or Mixed Platform. I also tried using a clean install of Gallio 64-bit and Gallio x86 to no avail.


On Friday, August 13, 2010 12:18:40 PM UTC-7, Yann Trevin wrote:
ECHO....ECHO... Echo.... echo... 

:D

2010/8/13 Rob Prouse <rpr...@gmail.com>
Sorry for the dupe, I had originally sent from an email address that is not
subscribed. The email didn't show up after a few hours, so I resent. I guess
the original eventually made its way through ;)

-----Original Message-----
From: galli...@googlegroups.com [mailto:gallio-dev@googlegroups.com] On
Behalf Of Graham Hay
Sent: Friday, August 13, 2010 5:41 AM
To: gallio-dev
Subject: Re: Testing mixed mode x86 assemblies throw BadImageFormatException

Is there an echo in here? :)

--
You received this message because you are subscribed to the Google Groups "gallio-dev" group.
To post to this group, send email to galli...@googlegroups.com.
To unsubscribe from this group, send email to gallio-dev+unsubscribe@googlegroups.com.

Vanessa McCallum

unread,
Jun 14, 2013, 1:49:43 PM6/14/13
to galli...@googlegroups.com, rpr...@gmail.com
Is there a fix for this issue? I am facing the same problem.
Reply all
Reply to author
Forward
0 new messages