Bug 321534 (MONO78816) - [gmcs] Generating invalid IL code
Summary: [gmcs] Generating invalid IL code
Status: RESOLVED FIXED
Alias: MONO78816
Product: Mono: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: 1.1
Hardware: Other Linux
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Paolo Molaro
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-11 11:47 UTC by Anders Lindström
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
testcase.cs (453 bytes, text/plain)
2006-07-11 11:49 UTC, Thomas Wiest
Details
Obtains the needed information to perform the verification (5.09 KB, patch)
2006-07-13 23:23 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:03:14 UTC


---- Reported by anders@tlabwest.se 2006-07-11 04:47:45 MST ----

Description of Problem:
gmcs (v1.1.16) generates invalid IL code with the attached testcase. The
testcase uses a static generic method called from a child class. 

Steps to reproduce the problem:
1. gmcs testcase.cs
2. mono testcase.exe

Actual Results:
Unhandled Exception: System.InvalidProgramException: Invalid IL code in
Testcase.BaseClass:TestGeneric (): IL_001d: callvirt  0x06000002

  at <0x00000> <unknown method>
  at Testcase.ChildClass.Main (System.String[] args) [0x00000]


Expected Results:
Clean run

How often does this happen? 
Always

Additional Information:
See attached testcase



---- Additional Comments From anders@tlabwest.se 2006-07-11 04:49:04 MST ----

Created an attachment (id=170085)
testcase.cs




---- Additional Comments From miguel@ximian.com 2006-07-12 17:29:28 MST ----

This is actually a verifier regression;  The code generated by the
compiler is correct.

The code generated by gmcs verifies and runs on MS.NET 



---- Additional Comments From miguel@ximian.com 2006-07-12 21:09:52 MST ----

I did some digging.

The problem is that the verifier uses the can_access_method assuming
the .NET 1.1 semantics, that is that the called method will have its
class set to the BaseClass (this is how it appears on the CIL
instruction stream).

But instead, since this method is generic, after the inflation the
class for the method is not the BaseClass, but the ChildClass, which
triggers this failure.

The issue is that we loose the information that the call is being done
to the abstract method in the current class.

A fix would be to return the method after decoding before the
inflation, and do the checks against that one.



---- Additional Comments From miguel@ximian.com 2006-07-13 16:22:22 MST ----

Here is a patch, I need it to get approved by Paolo though.



---- Additional Comments From miguel@ximian.com 2006-07-13 16:23:16 MST ----

Created an attachment (id=170086)
Obtains the needed information to perform the verification




---- Additional Comments From miguel@ximian.com 2006-07-26 14:39:06 MST ----

Am applying this fix.

Imported an attachment (id=170085)
Imported an attachment (id=170086)