[Mono-bugs] [Bug 348522] SIGABRT when a custom Binder doesn't convert parameters correctly

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Sep 3 02:52:09 EDT 2011


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

https://bugzilla.novell.com/show_bug.cgi?id=348522#c20


Stefan O'Rear <stefanor at cox.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stefanor at cox.net

--- Comment #20 from Stefan O'Rear <stefanor at cox.net> 2011-09-03 06:52:06 UTC ---
I just (re)discovered this bug, in a form that allows for complete subversion
of the type system:

stefan at stefans:/tmp$ cat Bindy.cs 
using System.Reflection;
using System.Globalization;
using System;

public class NullBinder: Binder {
    public override FieldInfo BindToField (BindingFlags bindingAttr,
FieldInfo[] match, object value, CultureInfo culture) { throw new
NotImplementedException(); }
    public override MethodBase BindToMethod (BindingFlags bindingAttr,
MethodBase[] match, ref object[] args, ParameterModifier[] modifiers,
CultureInfo culture, string[] names, out object state) { throw new
NotImplementedException(); }
    public override void ReorderArgumentArray( ref object[] args, object state)
{ throw new NotImplementedException(); }
    public override MethodBase SelectMethod (BindingFlags bindingAttr,
MethodBase[] match, Type[] types, ParameterModifier[] modifiers) { throw new
NotImplementedException(); }
    public override PropertyInfo SelectProperty( BindingFlags bindingAttr,
PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[]
modifiers) { throw new NotImplementedException(); }

    public override object ChangeType (object value, Type type, CultureInfo
culture) {
        return value;
    }
}

public class MainClass {
    public class C1 {
        public int length;
        public char c0,c1,c2,c3,c4,c5,c6,c7,c8,c9;
    }

    public static void TestFunc(C1 hole) {
        hole.c2 = 'a';
        hole.c3 = 't';
    }

    public static void Main(string[] args) {
        string s = "This is a string";

        typeof(MainClass).GetMethod("TestFunc").Invoke(null, 0, new
NullBinder(), new object[] { s }, null);

        Console.WriteLine(s);
    }
}
stefan at stefans:/tmp$ mcs Bindy.cs
stefan at stefans:/tmp$ mono --security=core-clr Bindy.exe 
That is a string
stefan at stefans:/tmp$ mono --version
Mono JIT compiler version 2.11 (master/41f79be Wed Jun 15 15:46:08 PDT 2011)
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  x86
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            Included Boehm (with typed GC and Parallel Mark)
stefan at stefans:/tmp$

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