Bugzilla – Bug 321534
[gmcs] Generating invalid IL code
Last modified: 2007-09-15 21:24:46 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)