[Mono-bugs] [Bug 368447] New: vbnc: miscompile when ByRef ValueType parameter

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Mar 8 08:39:00 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=368447


           Summary: vbnc: miscompile when ByRef ValueType parameter
           Product: Mono: Compilers
           Version: 1.2.6
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Basic
        AssignedTo: rkvinge at novell.com
        ReportedBy: andyhume32 at yahoo.co.uk
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Present in 1.2.6, 1.9 etc.

A null reference occurs at the second line in the called method:
[[
Structure SomeStruct 
  Private x As Integer
End Structure

Class ByRefValueType
  Public Shared Sub Main()
     Dim ss As SomeStruct
     ss.x = 55
     MethodByRefSomeStruct(ss)
  End Sub

  Shared Sub MethodByRefSomeStruct(ByRef ss As SomeStruct)
     Console.WriteLine(ss.x)
     Console.WriteLine(ss)
  Sub
End Class
]]

Depending on the presence of the member field, whether it contains zero, and
which method(s) are called in the callee method different errors occur at
runtime e.g. CLR crash, NullReferenceException, hang 100% cpu.  The first for
two are seen on the MSFT CLR too. 


This next fails with:
[[
Unhandled Exception: System.InvalidProgramException: Invalid IL code in
ByRefValueType:MethodSomeStructByRef (SomeStruct&): IL_0002: stloc.0
]]

[[
Public Structure SomeStruct
    Private x As Integer
    Private y As Integer
End Structure

Public Class ByRefValueType
    Shared Sub Main()
        Dim ss As SomeStruct
        MethodSomeStructByRef(ss)
    End Sub

    Shared Sub MethodSomeStructByRef(ByRef ss As SomeStruct)
        Dim ssLocal As SomeStruct = ss
        Console.WriteLine("success")
    End Sub
End Class
]]


Just for fun, guess what the output of this program, on both CLRs:
[[
Public Structure SomeStruct
   Private x As Integer
    Private y As Integer
End Structure

Public Class ByRefValueType
   Shared Sub Main()
       Dim ss As SomeStruct
       MethodSomeStructByRef(ss)
   End Sub

    Shared Sub MethodSomeStructByRef(ByRef ss As SomeStruct)
       Console.WriteLine(FooIsNull(ss))
   End Sub

    Shared Function FooIsNull(ByVal o As Object) As Boolean
        Return o Is Nothing
    End Function

End Class
]]

Yup, "True".  Null value types!!


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list