Bug 321300 (MONO78570) - Wrong/missing strack trace information for nested type method
Summary: Wrong/missing strack trace information for nested type method
Status: CONFIRMED
Alias: MONO78570
Product: Mono: Runtime
Classification: Mono
Component: debug (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-02 22:11 UTC by Rodrigo Oliveira
Modified: 2011-06-02 18:01 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:00:41 UTC


---- Reported by rodrigobamboo@gmail.com 2006-06-02 15:11:51 MST ----

The following boo application:

    class Foo:
        def zeng():
            return Bar().baz()

    class Bar:
        def baz():
            raise "ai"
            return 42

    Foo().zeng()

when compiled and ran with the latest mono (1.1.15) produces the following
stack trace output:

Unhandled Exception: System.ApplicationException: ai
in [0x0000a] (at SimpleBoo.boo:6) Bar:baz ()
in [0x00005] (at SimpleBoo.boo:3) Foo:zeng ()
in [0x00005] (at SimpleBoo.boo:9) SimpleBooModule:Main (System.String[] argv)

with correct line information. The basic same program but defining Bar as a
nested type:

    class Foo:
        def zeng():
            return Bar().baz()
        class Bar:
            def baz():
                raise "ai"
                return 42

    Foo().zeng()


fails to provide correct line numbers for the nested type method:

Unhandled Exception: System.ApplicationException: ai
in <0x0002e> Foo+Bar:baz ()
in [0x00005] (at SimpleBoo.boo:3) Foo:zeng ()
in [0x00005] (at SimpleBoo.boo:9) SimpleBooModule:Main (System.String[] argv)

Both programs output the correct stack trace information on ms.net.



---- Additional Comments From miguel@ximian.com 2006-06-03 12:28:15 MST ----

This looks like a bug/limitation in Boo, the equivalent C# code
compiled with mcs works.

using System;
class Foo {
	int Zeng ()
	{
		return new Bar ().Baz ();
	}

public	class Bar {
		public int Baz ()
		{
			throw new Exception ();
		}
	}

	static void Main ()
	{
		new Foo ().Zeng ();
	}
}

Setting bug to NEEDINFO.



---- Additional Comments From rodrigobamboo@gmail.com 2006-06-03 12:41:12 MST ----

Well it might be something that mcs is doing to circumvent a
System.Reflection.Emit bug or a runtime bug. 

The fact is that the same boo program compiled with the ms runtime
(without any changes to the boo compiler or to the program) and ran
with the ms runtime outputs the correct stack trace. I would assume
this is enough evidence of either a SRE or runtime bug.





---- Additional Comments From miguel@ximian.com 2006-06-03 13:26:26 MST ----

Please provide a small C#-based test case that illustrates the problem.  

In addition, I realize this is an urgent bug for you, but the only
person that can fix this will not be around to fix this bug on time
for your release he is on vacation.



---- Additional Comments From rodrigobamboo@gmail.com 2006-06-05 15:58:31 MST ----

using System;
using System.IO;
using System.Reflection.Emit;
using System.Reflection;
using System.Diagnostics.SymbolStore;

namespace BugReport
{
    public interface IFoo
    {
        void Bar();
    }

    class Program
    {
        const string DocumentPath = "/temp/test.cs";

        static void Main(string[] args)
        {
            IFoo foo = EmitFoo();
            try
            {
                foo.Bar();
            }
            catch (Exception x)
            {
                Assert(x.StackTrace.IndexOf(DocumentPath) != -1);
            }
        }
        
        static void Assert(bool condition)
        {
            if (!condition) throw new ApplicationException();
        }

        static IFoo EmitFoo()
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;
            string fname = Path.Combine(currentDomain.BaseDirectory,
"bugged.dll");

            AssemblyName name = new AssemblyName();
            name.Name = Path.GetFileNameWithoutExtension(fname);

            AssemblyBuilder builder =
currentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Save,
Path.GetDirectoryName(fname), null);
            ModuleBuilder module =
builder.DefineDynamicModule(Path.GetFileName(fname), true);
            ISymbolDocumentWriter document =
module.DefineDocument(DocumentPath, SymDocumentType.Text,
SymLanguageType.CSharp, Guid.Empty);

            TypeBuilder outer = module.DefineType("Outer",
TypeAttributes.Public | TypeAttributes.Class, typeof(object));
            TypeBuilder inner = outer.DefineNestedType("Inner",
TypeAttributes.NestedPublic | TypeAttributes.Class, typeof(object));
            string typeName = "Outer+Inner";
            //comment out the two lines above and uncomment the two lines
            // below to see mono working
            //TypeBuilder inner = module.DefineType("Inner",
TypeAttributes.Public | TypeAttributes.Class, typeof(object));
            //string typeName = "Inner";
            inner.AddInterfaceImplementation(typeof(IFoo));

            MethodBuilder foo = inner.DefineMethod("Bar",
MethodAttributes.Public | MethodAttributes.Virtual, typeof(void), new
Type[0]);
            ILGenerator il = foo.GetILGenerator();
            il.MarkSequencePoint(document, 10, 0, 11, 0);
            il.ThrowException(typeof(ApplicationException));
            // MONO uses the next sequence point as the line number
for the
            // exception above
            il.MarkSequencePoint(document, 10, 0, 11, 0);
            il.Emit(OpCodes.Ret);

            inner.CreateType();
            outer.CreateType();

            builder.Save(Path.GetFileName(fname));
            return
(IFoo)Activator.CreateInstance(Assembly.LoadFrom(fname).GetType(typeName));
        }
    }
}




---- Additional Comments From martin@ximian.com 2006-06-12 09:29:53 MST ----

Same here.


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Windows XP</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".