New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The throw keyword shows the wrong thrown exception line #9518
Comments
From @Clockwork-Muse on August 22, 2017 16:1 ... this is the behavior of the standard framework, too, though (And I'm on Win7 at the moment). I'd consider this (mostly) expected behavior. It might be better to restate this as a request along the lines of:
|
From @danmosemsft on August 22, 2017 16:8 I see the same behavior in desktop back to 2.0. Which isn't to say ideally it would be improved. |
From @danmosemsft on August 23, 2017 0:10 In fact I remember logging this as a bug many years ago. @jkotas is this (reset of line number of frame in which |
I do not see a fundamental problem with fixing it in .NET Core. The usual due-diligence with figuring out the breaking potential of the change would apply. Do you happen to have the bug number that you have filled years ago? Note that C# let's you write exception filters that solve the problem of catching exception conditionally as well. The filters give you even better diagnostic experience because of the crash dump will have the stacktrace of the original throw site preserved.
|
From @NicolasDorier on August 23, 2017 1:59 Really it is expected behavior? I am coding in .NET since 2007 or something... it turns out I only noticed out now...
You solved another big mystery for me: I had no idea why Exception filter were useful. |
From @NicolasDorier on August 23, 2017 2:1 @jkotas Ha, you are right, I thought it was specific to .NET Core, but it turns out it does not, it has always been that way. https://www.thomaslevesque.com/2015/06/21/exception-filters-in-c-6/ |
From @NicolasDorier on August 23, 2017 2:1 You may close this issue or keep it open if you think improving it in .NET core in the future. |
From @joperezr on September 14, 2017 22:44 Closing for now given the above discussion. Feel free to reopen if needed. |
From @danmosemsft on December 6, 2017 23:35 I don't think anyone wants the line number on the |
* Show the expected stack trace from a rethrown exception. Fix #15780 * Remove now unused methods - StackTraceArray::AppendSkipLast - StackTraceElement::PartiallyEqual - StackTraceElement::PartialAtomicUpdate
I can't believe this is really happening! 🎉 |
@danmosemsft, will this change be included in .NET Core 2.1? Thx! |
Yes! That is what I immediately wanted to know! This would be very interesting to a large group of people. |
@fujiy yes this will be in .NET Core 2.1, albeit not in the Preview 1 as that branched already. I don't think CoreFX ingested it yet, but in a few days, please try it in master. For .NET Framework - it is marked netfx-port-consider for our next pass through potential ports. I can't give a timeframe for that. |
@danmosemsft, @jkotas, @ateoi. Considering the following example:
Wouldn't be better to keep both frames (the throwing and the re-throwing ones)? This way it would be easier to identify which catch block captured the exception in DoStuff() method. In this case the output would be:
instead of:
|
* Added tests to verify the reported call stacks for rethrown exceptions, as specified by dotnet/coreclr#15780. 1. Exception rethrown in a method different than the method where it was originally thrown: the stack trace contains both the location in the method where the exception was originally thrown, and the location where the method that threw the exception was called. 2. Exception is thrown and later rethrown in the same method: the stack trace only contains the location where the exception was originally thrown and does not include the location where the exception was rethrown. * - Make test work with full framework. Test will fail after porting dotnet/core#15780 to full framework. - Fixed variable name * Write reported call stack to console Writing call stack to console to debug test errors on NETFX and Linux. * Add netfx configuration to test project * Remove redundant throw A redundant throw in "ThrowAndRethrowOtherMethod" was being removed by the optimizer and causing error in exception line calculation. * Remove full call stack verification Verify only the rethrown stack frame due to inconsistencies found on build/release exception call stacks - #28059 (comment)
@danmosemsft did this end up getting ported to X version of the netfx? Is there a good way in general of telling which issues labelled 'netfx-port-consider' got addressed or not? Thanks! |
It was not ported. The .NET Framework release notes list all changes that went into particular .NET Framework version, e.g. https://github.com/microsoft/dotnet/tree/master/releases/net48 |
From @NicolasDorier on August 22, 2017 14:56
Using .NETCore2.0, Win10, it seems the
throw
keyworUsing the
throw
keyword loose all the initial stacktrace information.You can workaround with
ExceptionDispatchInfo.Capture(ex).Throw();
, but this seems like a bug to me.Actual output: (Exception line 28)
Expected output: (Exception line 24)
Workaround using
ExceptionDispatchInfo.Capture(ex).Throw();
:Copied from original issue: dotnet/corefx#23470
The text was updated successfully, but these errors were encountered: