Bug 58581 - Calling a generic local function with a dynamic parameter produce a BadImageFormatException
Summary: Calling a generic local function with a dynamic parameter produce a BadImageF...
Status: RESOLVED UPSTREAM
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: 5.0 (2017-02)
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2017-08-03 23:36 UTC by nasonov256
Modified: 2017-08-04 10:04 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Code demonstrating bug effect (624 bytes, text/plain)
2017-08-03 23:36 UTC, nasonov256
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description nasonov256 2017-08-03 23:36:22 UTC
Created attachment 24020 [details]
Code demonstrating bug effect

Mono JIT cannot compile the function that has a call to local generic function with a dynamic parameter.
The program (see attached file) produces the following output:

$ mono BadImageFormatException.exe
Entered Main

Unhandled Exception:
System.BadImageFormatException: Method with open type while not compiling gshared
File name: 'BadImageFormatException'
  at BadImageFormatException.Program.Main (System.String[] args) [0x0000c] in <0886b0c0d82b43f2b9287305a0b2668b>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.BadImageFormatException: Method with open type while not compiling gshared
File name: 'BadImageFormatException'
  at BadImageFormatException.Program.Main (System.String[] args) [0x0000c] in <0886b0c0d82b43f2b9287305a0b2668b>:0

Microsoft .NET 4.7 JIT has the same problem.
The problem appears in both x86, x64, Debug and Release modes.

The discussion is also available here:
https://stackoverflow.com/questions/45495869/why-does-calling-a-generic-local-function-with-a-dynamic-parameter-produce-a-bad
Comment 1 Marek Safar 2017-08-04 10:04:59 UTC
This is C# compiler (csc) bug. Please fill the bug report at https://github.com/dotnet/roslyn/issues