Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: MyndFyre on June 24, 2008, 03:25:05 AM

Title: .NET MDA being invoked
Post by: MyndFyre on June 24, 2008, 03:25:05 AM
Code:

        protected virtual void OnConnected(EventArgs e)
        {
            foreach (EventHandler eh in __Connected[Priority.High])
            {
                try
                {
                    eh(this, e);
                }
                catch (Exception ex)
                {
                    ReportException(
                        ex,
                        new KeyValuePair<string, object>("delegate", eh),
                        new KeyValuePair<string, object>("Event", "Connected"),
                        new KeyValuePair<string, object>("param: priority", Priority.High),
                        new KeyValuePair<string, object>("param: this", this),
                        new KeyValuePair<string, object>("param: e", e)
                        );
                }
            }

            ThreadPool.QueueUserWorkItem((WaitCallback)delegate
            {
                foreach (EventHandler eh in __Connected[Priority.Normal])
                {
                    try
                    {
                        eh(this, e);
                    }
                    catch (Exception ex)
                    {
                        ReportException(
                            ex,
                            new KeyValuePair<string, object>("delegate", eh),
                            new KeyValuePair<string, object>("Event", "Connected"),
                            new KeyValuePair<string, object>("param: priority", Priority.Normal),
                            new KeyValuePair<string, object>("param: this", this),
                            new KeyValuePair<string, object>("param: e", e)
                            );
                    }
                }
                ThreadPool.QueueUserWorkItem((WaitCallback)delegate
                {
                    foreach (EventHandler eh in __Connected[Priority.Low])
                    {
                        try
                        {
                            eh(this, e);
                        }
                        catch (Exception ex)
                        {
                            ReportException(
                                ex,
                                new KeyValuePair<string, object>("delegate", eh),
                                new KeyValuePair<string, object>("Event", "Connected"),
                                new KeyValuePair<string, object>("param: priority", Priority.Low),
                                new KeyValuePair<string, object>("param: this", this),
                                new KeyValuePair<string, object>("param: e", e)
                                );
                        }
                    }
                    FreeArgumentResources(e as BaseEventArgs);
                });
            });
        }


FatalExecutionEngineError Managed Debugging Assistant comes up with:
Quote
The runtime has encountered a fatal error. The address of the error was at 0x7f578493, on thread 0x14ec. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
(Note 0xc0000005 is ACCESS_VIOLATION).

I doubt I'll get much help but, thoughts?

Also, yes, if I take out the anonymous delegate calls and make those calls inline without a separate thread, the error goes away.
Title: Re: .NET MDA being invoked
Post by: Lead on July 09, 2008, 05:43:33 PM
Quote from: MyndFyre on June 24, 2008, 03:25:05 AM
Code:

        protected virtual void OnConnected(EventArgs e)
        {
            foreach (EventHandler eh in __Connected[Priority.High])
            {
                try
                {
                    eh(this, e);
                }
                catch (Exception ex)
                {
                    ReportException(
                        ex,
                        new KeyValuePair<string, object>("delegate", eh),
                        new KeyValuePair<string, object>("Event", "Connected"),
                        new KeyValuePair<string, object>("param: priority", Priority.High),
                        new KeyValuePair<string, object>("param: this", this),
                        new KeyValuePair<string, object>("param: e", e)
                        );
                }
            }

            ThreadPool.QueueUserWorkItem((WaitCallback)delegate
            {
                foreach (EventHandler eh in __Connected[Priority.Normal])
                {
                    try
                    {
                        eh(this, e);
                    }
                    catch (Exception ex)
                    {
                        ReportException(
                            ex,
                            new KeyValuePair<string, object>("delegate", eh),
                            new KeyValuePair<string, object>("Event", "Connected"),
                            new KeyValuePair<string, object>("param: priority", Priority.Normal),
                            new KeyValuePair<string, object>("param: this", this),
                            new KeyValuePair<string, object>("param: e", e)
                            );
                    }
                }
                ThreadPool.QueueUserWorkItem((WaitCallback)delegate
                {
                    foreach (EventHandler eh in __Connected[Priority.Low])
                    {
                        try
                        {
                            eh(this, e);
                        }
                        catch (Exception ex)
                        {
                            ReportException(
                                ex,
                                new KeyValuePair<string, object>("delegate", eh),
                                new KeyValuePair<string, object>("Event", "Connected"),
                                new KeyValuePair<string, object>("param: priority", Priority.Low),
                                new KeyValuePair<string, object>("param: this", this),
                                new KeyValuePair<string, object>("param: e", e)
                                );
                        }
                    }
                    FreeArgumentResources(e as BaseEventArgs);
                });
            });
        }


FatalExecutionEngineError Managed Debugging Assistant comes up with:
Quote
The runtime has encountered a fatal error. The address of the error was at 0x7f578493, on thread 0x14ec. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
(Note 0xc0000005 is ACCESS_VIOLATION).

I doubt I'll get much help but, thoughts?

Also, yes, if I take out the anonymous delegate calls and make those calls inline without a separate thread, the error goes away.

Q: What version of the framework are you compiling on?
Title: Re: .NET MDA being invoked
Post by: MyndFyre on July 10, 2008, 03:30:15 AM
I'm compiling to 2.0.

I actually fixed the issue - it was a very, very weird parameter binding issue dealing with using a params[] parameter list instead of a defined parameter list.  Funkified.