Skip to content
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

StackTrace reports wrong line number for throwing if-statement #13763

Closed
glatzert opened this issue Nov 8, 2019 · 2 comments
Closed

StackTrace reports wrong line number for throwing if-statement #13763

glatzert opened this issue Nov 8, 2019 · 2 comments
Assignees
Milestone

Comments

@glatzert
Copy link

glatzert commented Nov 8, 2019

A similar case has been reported in #13098 for while loops.

The debug output of a thrown exception will report the wrong line in stack-traces.

Repro:

using System;

namespace WrongExceptionLine
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            if (System.DateTime.Today.Year > 2000)
                throw new Exception("Exception line should be 12.");

            Console.WriteLine("Goodbye World!");
        }
    }
}

Will report

Hello World!
Unhandled exception. System.Exception: Exception line should be 12.
at WrongExceptionLine.Program.Main(String[] args) in C:...\WrongExceptionLine\Program.cs:line 14

@AaronRobinsonMSFT
Copy link
Member

/cc @noahfalk

@mikem8361 mikem8361 self-assigned this Nov 8, 2019
mikem8361 referenced this issue in mikem8361/diagnostics Jan 7, 2020
Reported issues https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message

Gracefully fail with runtime module size == 0

Add some more PrintException -lines testing
mikem8361 referenced this issue in mikem8361/diagnostics Jan 8, 2020
Reported issues https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message

Gracefully fail with runtime module size == 0

Add some more PrintException -lines testing
mikem8361 referenced this issue in mikem8361/diagnostics Jan 8, 2020
Reported issues https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message

Gracefully fail with runtime module size == 0

Add some more PrintException -lines testing
mikem8361 referenced this issue in mikem8361/diagnostics Jan 8, 2020
Reported issues https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message

Gracefully fail with runtime module size == 0

Add some more PrintException -lines testing
mikem8361 referenced this issue in mikem8361/diagnostics Jan 8, 2020
The change is to subtract 1 from the IP used to get the source/line info when the stack frame is a leaf node. For hardware exceptions, the IP has already been adjusted (+1) by the runtime so they cancel out.

Fixes in SOS the same issues reported in https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message.

Add some more PrintException -lines testing for thrown and hardware exceptions.

Gracefully fail with runtime module size == 0.
mikem8361 referenced this issue in mikem8361/diagnostics Jan 10, 2020
The change is to subtract 1 from the IP used to get the source/line info when the stack frame is a leaf node. For hardware exceptions, the IP has already been adjusted (+1) by the runtime so they cancel out.

Fixes in SOS the same issues reported in https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message.

Add some more PrintException -lines testing for thrown and hardware exceptions.

Gracefully fail with runtime module size == 0.
mikem8361 referenced this issue in mikem8361/diagnostics Jan 11, 2020
The change is to subtract 1 from the IP used to get the source/line info when the stack frame is a leaf node. For hardware exceptions, the IP has already been adjusted (+1) by the runtime so they cancel out.

Fixes in SOS the same issues reported in https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message.

Add some more PrintException -lines testing for thrown and hardware exceptions.

Gracefully fail with runtime module size == 0.

Fix "clrmodules" failure our vendors found.
mikem8361 referenced this issue in mikem8361/diagnostics Jan 11, 2020
The change is to subtract 1 from the IP used to get the source/line info when the stack frame is a leaf node. For hardware exceptions, the IP has already been adjusted (+1) by the runtime so they cancel out.

Fixes in SOS the same issues reported in https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message.

Add some more PrintException -lines testing for thrown and hardware exceptions.

Gracefully fail with runtime module size == 0.

Fix "clrmodules" failure our vendors found.
mikem8361 referenced this issue in mikem8361/diagnostics Jan 14, 2020
The change is to subtract 1 from the IP used to get the source/line info when the stack frame is a leaf node. For hardware exceptions, the IP has already been adjusted (+1) by the runtime so they cancel out.

Fixes in SOS the same issues reported in https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message.

Add some more PrintException -lines testing for thrown and hardware exceptions.

Gracefully fail with runtime module size == 0.

Fix "clrmodules" failure our vendors found.
mikem8361 referenced this issue in dotnet/diagnostics Jan 14, 2020
Fix line number issues in SOS

The change is to subtract 1 from the IP used to get the source/line info when the stack frame is a leaf node. For hardware exceptions, the IP has already been adjusted (+1) by the runtime so they cancel out.

Fixes in SOS the same issues reported in https://github.com/dotnet/coreclr/issues/27765 and https://github.com/dotnet/coreclr/issues/25740 for the runtime's unhandled exception message.

Add some more PrintException -lines testing for thrown and hardware exceptions.

Gracefully fail with runtime module size == 0.

Fix "clrmodules" failure our vendors found.

Add line number (LineNum) check testcase
@mikem8361
Copy link
Member

Fix in PR #2269

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 5.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants