[Mono-bugs] [Bug 673645] New: Method passed to native code as callback is called with 'this' reference equaling 'null'

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Feb 20 16:54:42 EST 2011


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

https://bugzilla.novell.com/show_bug.cgi?id=673645#c0


           Summary: Method passed to native code as callback is called
                    with 'this' reference equaling 'null'
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.10.x
          Platform: x86-64
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: JulianBrunner at gmx.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Created an attachment (id=415190)
 --> (http://bugzilla.novell.com/attachment.cgi?id=415190)
A test case for the described bug

Description of Problem:
When passing a managed (non-static) method to native code as a callback, it is
sometimes called with the 'this' reference equaling 'null'. This causes every
access to another member of that object to throw a 'NullReferenceException'.

Steps to reproduce the problem:
1. Unpack the attached tarball containing the test case.
2. Use make to build the managed executable "Test.exe" and the native library
"libtest.so".
3. Run the "Test.exe" executable using mono.

Actual Results:
It outputs a few hundred lines of "False", since the expression 'this == null'
evaluates to 'false', but then it starts printing "True" lines, indicating that
'this' actually is 'null'.

Expected Results:
I would expect it to always print "False" since 'this' should never be 'null'.

How often does this happen? 
Every time I run the test case.

Additional Information:
There seem to be some very subtle conditions to when this actually happens. For
example, removing the "new object();" statement in the callback method makes
the test case produce the expected result. The provided test case is the most
simple test case I could come up with, which produces the described behavior.

I tested the behavior using .NET on Windows and it matches the expected
behavior.

This was tested using Ubuntu 10.10 (x64) using a mono 2.10 source tarball.

-- 
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