Bug 59689 - System.Diagnostics.StackTrace.GetFrames() does not consider captured_traces
Summary: System.Diagnostics.StackTrace.GetFrames() does not consider captured_traces
Status: RESOLVED NORESPONSE
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 5.2 (2017-04)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-22 11:50 UTC by ivankoster
Modified: 2018-03-13 11:07 UTC (History)
2 users (show)

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


Attachments
Sample project reproducing the bug (2.35 KB, application/x-zip-compressed)
2017-09-25 10:23 UTC, ivankoster
Details


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 NORESPONSE

Description ivankoster 2017-09-22 11:50:29 UTC
When I get Exception.StackTrace.ToString() on mono I receive a bunch of info from async code, with this line seperator
--- End of stack trace from previous location where exception was thrown ---
but when i access
var stackTrace = new StackTrace(ex, false); stackTrace.GetFrames();
i only get the last few frames, those that are written under the last --- End of stack trace from previous location where exception was thrown --- in the ToString() output.

I'm using:
a library targeting .net standard 1.6
System.Diagnostics.StackTrace nuget package 4.3.0
Compiled for .net framework 4.6.1
running on mono:5.2 docker container.

When running on .net framework 4.6.1 on windows without mono, or netcoreapp2.0 on windows I get all the frames with stackTrace.GetFrames();

Most likely issue is that the implementation of stackTrace.GetFrames() does not consider the captured_traces variable, which the ToString() method does.
Comment 1 Marek Safar 2017-09-22 21:39:29 UTC
Thank you for your report!

I’m unable to reproduce this issue locally using the information you provided. In order to investigate the issue further can you please attach a reproduction project and steps to reproduce this issue? For help on writing a bug report, please see our guide on this topic:

https://bugzilla.xamarin.com/page.cgi?id=bug-writing.html

Some of your next steps would be:

1. Including a sample project or steps to reproduce this problem
2. Your Version Information
3. Your expected results and actual results

Thank you!
Comment 2 ivankoster 2017-09-25 10:23:35 UTC
Created attachment 24909 [details]
Sample project reproducing the bug

Compile the sample project with Visual Studio 2017 15.3.4 - Release - Any CPU

run on Mono JIT compiler version 5.2.0.224 (tarball Mon Sep 18 17:33:46 UTC 2017)
Comment 3 ivankoster 2017-09-25 10:25:17 UTC
I attached a reproduce project to this bug report.

Compile the sample project with Visual Studio 2017 15.3.4 - Release - Any CPU

net461 windows (NO mono) | output:
Programmatically inspecting stacktrace with StackTrace class
Assembly: ExceptionHelper Method: MoveNext
Assembly: mscorlib Method: Throw
Assembly: mscorlib Method: HandleNonSuccessAndDebuggerNotification
Assembly: ExceptionHelper Method: MoveNext
Assembly: mscorlib Method: Throw
Assembly: mscorlib Method: HandleNonSuccessAndDebuggerNotification
Assembly: ExceptionHelper Method: MoveNext

--------------------------------
netcoreapp2.0 running on windows | output:
Programmatically inspecting stacktrace with StackTrace class
Assembly: ExceptionHelper Method: MoveNext
Assembly: System.Private.CoreLib Method: Throw
Assembly: System.Private.CoreLib Method: HandleNonSuccessAndDebuggerNotification
Assembly: ExceptionHelper Method: MoveNext
Assembly: System.Private.CoreLib Method: Throw
Assembly: System.Private.CoreLib Method: HandleNonSuccessAndDebuggerNotification
Assembly: ExceptionHelper Method: MoveNext

----------------------------------------------------------
net461 on mono:latest docker linux container on "Docker For Windows" | output:

/testBug# cli --version
Mono JIT compiler version 5.2.0.224 (tarball Mon Sep 18 17:33:46 UTC 2017)

Programmatically inspecting stacktrace with StackTrace class
Assembly: mscorlib Method: Throw
Assembly: mscorlib Method: ThrowForNonSuccess
Assembly: mscorlib Method: HandleNonSuccessAndDebuggerNotification
Assembly: mscorlib Method: ValidateEnd
Assembly: mscorlib Method: GetResult
Assembly: ExceptionHelper Method: MoveNext

---------------------------------------------------------
You can clearly see in the upper two outputs the StackFrame with
"Assembly: ExceptionHelper Method: MoveNext"
appears 3 times. This corresponds to the methods Class2.DoSomethingAsync() and Class1.DoSomethingAsync() and Class1.ShowMeTheBug()
In the last output (mono) it only appears once.
This corresponds to Class1.ShowMeTheBug().

My expectation is that if stackTrace.GetFrames() on Windows returns the stackframes of all continuations, it also does this on Mono.

Why i need this:
I'm using this to determine at runtime from which 3rd party libraries an exception came, and the fullyQualified name of the exception does not provide enough information to tell the exceptions apart.
Comment 4 Marek Safar 2018-03-13 11:07:04 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!