Bug 643371

Summary: Rethrow doesn't preserve stack trace
Product: [Mono] Mono: Runtime Reporter: Tomas Matousek <tomas.matousek>
Component: debugAssignee: Martin Baulig <martin>
Status: RESOLVED DUPLICATE QA Contact: Mono Bugs <mono-bugs>
Severity: Major    
Priority: P5 - None CC: forgotten_vxPDddArjq
Version: 2.8.x   
Target Milestone: ---   
Hardware: x86   
OS: Windows 7   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Tomas Matousek 2010-10-03 01:42:17 UTC
User-Agent:       Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)

The methods above the frame that rethrows aren't included in the frames constructed from an exception object: new System.Diagnostics.StackTrace(e)

This bug prevents IronRuby to display correct stack traces.

Reproducible: Always

Steps to Reproduce:
Compile and run the following code:

using System;
using System.Runtime.CompilerServices;


public class C {

    public static void Main() {
        Baz();
    }
    
    [MethodImpl(MethodImplOptions.NoInlining)]
    public static void Baz() {
        try {
            Bar();
        } catch(Exception e) {
            Console.WriteLine(new System.Diagnostics.StackTrace(e));
        }
    }
    
    [MethodImpl(MethodImplOptions.NoInlining)]
    public static void Bar() {
        try {
          Foo();
        } catch {
          throw;
        }
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    public static void Foo() {
        throw new Exception();
    }

}
Actual Results:  
   at C.Foo()
   at C.Bar()

Expected Results:  
   at C.Foo()
   at C.Bar()
   at C.Baz()
Comment 1 Forgotten User vxPDddArjq 2010-10-04 00:11:10 UTC
duplicate.

*** This bug has been marked as a duplicate of bug 322158 ***