[Mono-bugs] [Bug 457257] New: Compiler crashes trying to find a member to override
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon Dec 8 09:57:48 EST 2008
https://bugzilla.novell.com/show_bug.cgi?id=457257
Summary: Compiler crashes trying to find a member to override
Product: Mono: Compilers
Version: SVN
Platform: x86-64
OS/Version: Ubuntu
Status: NEW
Severity: Major
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: michiel at eurotrol.com
QAContact: mono-bugs at lists.ximian.com
Found By: Customer
Description of Problem:
The compiler crashes with a null reference exception when trying to compile the
programme below
Steps to reproduce the problem:
1. Create a file "test.cs" (name not important) with the following content:
-------- START FILE --------------
namespace ETDB
{
public class Exception : System.Exception
{
string _message="";
public Exception(string msg)
{
_message = msg;
}
public string message
{
get { return _message; }
}
}
}
--------- END FILE ---------------
2. Then compile the file using
gmcs -pkg:dotnet -target:library -debug -out:test.dll test.cs
Actual Results:
Unhandled Exception: Mono.CSharp.InternalErrorException: test.cs(12,23):
ETDB.Exception.message ---> System.NullReferenceException: Object reference not
set to an instance of an object
at Mono.CSharp.MemberCache.FindMemberToOverride (System.Type invocation_type,
System.String name, Mono.CSharp.AParametersCollection parameters,
Mono.CSharp.GenericMethod generic_method, Boolean is_property) [0x00000]
at Mono.CSharp.Property.ResolveBaseProperty () [0x00000]
at Mono.CSharp.PropertyBase.FindOutBaseMethod (System.Type& base_ret_type)
[0x00000]
at Mono.CSharp.InterfaceMemberBase.CheckBase () [0x00000]
at Mono.CSharp.Property.Define () [0x00000]
at Mono.CSharp.TypeContainer+MemberCoreArrayList.DefineContainerMembers ()
[0x00000]
--- End of inner exception stack trace ---
at Mono.CSharp.TypeContainer+MemberCoreArrayList.DefineContainerMembers ()
[0x00000]
at Mono.CSharp.TypeContainer.DefineContainerMembers
(Mono.CSharp.MemberCoreArrayList mcal) [0x00000]
at Mono.CSharp.Class.DefineContainerMembers (Mono.CSharp.MemberCoreArrayList
list) [0x00000]
at Mono.CSharp.TypeContainer.DoDefineMembers () [0x00000]
at Mono.CSharp.Class.DoDefineMembers () [0x00000]
at Mono.CSharp.TypeContainer.Define () [0x00000]
at Mono.CSharp.ClassOrStruct.Define () [0x00000]
at Mono.CSharp.Class.Define () [0x00000]
at Mono.CSharp.RootContext.PopulateTypes () [0x00000]
at Mono.CSharp.Driver.Compile () [0x00000]
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000]
Expected Results:
A file called test.dll with a namespace specific exception object.
How often does this happen?
Always.
Additional Information:
FindMemberToOverride is called with is_property set true.
In the method-chain-walk-loop, the mi variable is initialised null and remains
null because of is_property. The switch then jumps to case
FieldAttributes.Assembly/FieldAttributes.FamANDAssem, which accesses a member
of the mi object.
Patch as follows on mono-118180:
--- mcs/mcs/decl.cs 2008-12-02 12:59:11.000000000 +0100
+++ mcs/mcs/decl.cs.ori 2008-12-02 09:51:58.000000000 +0100
@@@ -2381,7 +2383,7 @@
//
// Check for assembly methods
//
- if (mi!= null &&
mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
+ if (mi.DeclaringType.Assembly
!= CodeGen.Assembly.Builder)
continue;
break;
}
Please note, I did not check if this should have been:
if (mi != null && mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
or
if (mi == null || mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
The former seems to produce working output in my production environment,
although it was not stress-tested.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list