Bug 23749 - System.InvalidProgramException in mangled names
Summary: System.InvalidProgramException in mangled names
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-10-10 17:27 UTC by Marek Safar
Modified: 2014-11-12 11:13 UTC (History)
5 users (show)

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

test (6.50 KB, application/x-msdownload)
2014-10-10 17:27 UTC, Marek Safar
9-Rays Obfuscator Project (8.20 KB, application/octet-stream)
2014-11-07 15:12 UTC, Matt O'Connor
Console Application Source Code (30.99 KB, application/zip)
2014-11-07 15:40 UTC, Matt O'Connor

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:

Description Marek Safar 2014-10-10 17:27:21 UTC
Created attachment 8380 [details]

mono ConsoleApplication1.exe

Unhandled Exception:
System.InvalidProgramException: Invalid IL code in .: (): IL_002c: call      0x0600000c

Works on .net
Comment 1 Zoltan Varga 2014-10-10 17:34:56 UTC
So the problem is this code in the method decorated with the AsyncStateMachine attribute:

    IL_0027:  ldflda     valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ''.''/'<test>d__0'::'<>t__builder'
    IL_002c:  call       class [mscorlib]System.Threading.Tasks.Task ''.''/'В'::'њ'(object)

Here, we are loading the address of a valuetype and passing it as an object.
Comment 2 Rodrigo Kumpera 2014-11-04 12:02:32 UTC
It's a compiler issue then?
Comment 3 Marek Safar 2014-11-04 12:18:47 UTC
No, same IL works on .net
Comment 4 Zoltan Varga 2014-11-04 12:40:18 UTC
The obfuscator creates invalid il code, and ms.net somehow accepts it, probly by auto boxing the struct. So the problem has nothing to do with the mangled names.
Comment 5 Rodrigo Kumpera 2014-11-04 14:24:47 UTC
Do you guys know which obfuscator is doing that?

This would allow us to figure out if it's something we want to support or not.
Comment 6 Matt O'Connor 2014-11-07 11:40:52 UTC
The obfuscation used was 9-Rays Spices: http://www.9rays.net/Category/55-spicesnet-obfuscator.aspx
Comment 7 Rodrigo Kumpera 2014-11-07 14:52:38 UTC
Hi Matt,

Could you share your spices.project (.iloprj).

We're trying to reach our to the obfuscator vendor to have them address the problem in their product and they need those files.
Comment 8 Matt O'Connor 2014-11-07 15:12:46 UTC
Created attachment 8660 [details]
9-Rays Obfuscator Project

I attached the App1.iloprj file that was used to create the problematic exe. Thanks for your help!
Comment 9 Matt O'Connor 2014-11-07 15:40:02 UTC
Created attachment 8663 [details]
Console Application Source Code

Attaching ConsoleApplication1.zip, which contains the source code.
Comment 10 Rodrigo Kumpera 2014-11-12 11:13:10 UTC
I've been in touch with the obfuscator company to help them fix it.

We have no plans to support invalid programs just because dotnet under some circumstances does.