Bug 1147 - Generic method failing "at mini-generic-sharing.c:407, condition `!(*oti)->data' not met"
Summary: Generic method failing "at mini-generic-sharing.c:407, condition `!(*oti)->da...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Mac OS
: High normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 1618 ()
Depends on:
Blocks:
 
Reported: 2011-09-29 21:22 UTC by Phi
Modified: 2017-08-28 15:04 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Comment 1 Zoltan Varga 2011-10-04 00:29:37 UTC
You can run with -O=-gshared as a workaround. Would it be possible to extract a testcase from this app which doesn't depend on monomac etc. ?
Comment 2 Phi 2011-10-05 12:39:35 UTC
I tried making a simpler test case without monomac and mobcj, but that code didn't have any problem.
Comment 3 Phi 2011-10-05 17:46:33 UTC
I have a new test case.
Please notices my comments to see when the code break or not.

[START CODE]
using System;
using System.Collections.Generic;

namespace Program {
    public class AxControlEventArgs<T> : EventArgs where T : WindowlessControl {
        public T Control { get; private set; }

        public AxControlEventArgs(T control) {
            Control = control;
        }
    }
    public class AxControlEventArgs : AxControlEventArgs<WindowlessControl> {
        public AxControlEventArgs(WindowlessControl c) : base(c) { }
    }

    public class AlignPadLayoutPanel : AlignPadLayoutPanel<WindowlessControl> { }

    public class AlignPadLayoutPanel<T> : WindowlessControl where T : WindowlessControl {
        protected override void OnControlAdded(AxControlEventArgs e) {
            e.Control.Resize += Content_Resize; //OK if removed
            base.OnControlAdded(e);
        }

        private void Content_Resize(object sender, EventArgs e) { }
    }

    public class GroupBox : AlignPadLayoutPanel { } //NOT OK
    //public class GroupBox : AlignPadLayoutPanel<WindowlessControl> {} //OK

    public class Program {
        public static readonly AttachedProperty<string> EDITING_TEXT = new AttachedProperty<string>(null);

        static void Main(string[] args) {
            Console.WriteLine("Program 6");

            var gr = new GroupBox();

            //gr.InsertControl(0, new WindowlessControl()); //OK

            /* need this block(A) this to crash */
            var item = new WindowlessControl();

            new AlignPadLayoutPanel<WindowlessControl>().InsertControl(0, item); //OK if removed 

            item.SetAttachedProperty(EDITING_TEXT, "label.Text");
            /*end block(A)*/

            gr.InsertControl(0, new WindowlessControl()); //NOT OK			

            var wc = new WindowlessControl();
            wc.SetAttachedProperty(EDITING_TEXT, "label.Text");
            var str = wc.GetAttachedProperty(EDITING_TEXT);

            Console.WriteLine("DONE");
        }
    }

    //public static class WindowlessControlExtensions {
    //    public static void SetAttachedProperty<T>(this WindowlessControl c, AttachedProperty<T> prop, T val) {
    //        Console.WriteLine("ext SetAttachedProperty 1");
    //        c._AttachedProperties[prop] = val;
    //        Console.WriteLine("ext SetAttachedProperty 2");
    //    }

    //    public static T GetAttachedProperty<T>(this WindowlessControl c, AttachedProperty<T> prop) {
    //        Console.WriteLine("ext GET AttachedProperty");
    //        return (T)(c._AttachedProperties[prop] ?? prop.DefaultValue);
    //    }
    //}	

    public class WindowlessControl {
        internal readonly Dictionary<object, object> _AttachedProperties = new Dictionary<object, object>();

        public void SetAttachedProperty<T>(AttachedProperty<T> prop, T val) {
            Console.WriteLine("SetAttachedProperty 1");
            _AttachedProperties[prop] = val;
            Console.WriteLine("SetAttachedProperty 2");
        }

        public T GetAttachedProperty<T>(AttachedProperty<T> prop) {
            Console.WriteLine("GET AttachedProperty");
            return (T)(_AttachedProperties[prop] ?? prop.DefaultValue);
        }

        public event EventHandler Resize;

        public void InsertControl(int index, WindowlessControl control) {
            OnControlAdded(new AxControlEventArgs(control));
        }

        protected virtual void OnControlAdded(AxControlEventArgs e) { }
    }

    public struct AttachedProperty<T> {
        public T DefaultValue { get; private set; }

        public AttachedProperty(T defaultValue) : this() {
            DefaultValue = defaultValue;
        }
    }
}

[END CODE]
Comment 4 Zoltan Varga 2011-10-21 05:00:45 UTC
*** Bug 1618 has been marked as a duplicate of this bug. ***
Comment 6 Rodrigo Kumpera 2012-01-05 07:02:31 UTC
Fixed in master, 2.10 and MM