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
CLR profiling: DoStackSnapshot returns wrong Instruction Pointer #9448
Comments
@GalSvirin1: what platform are you running your test on? |
@lt72 I can confirm this happens to me on Windows x64. Can provide any further information needed. Thanks! |
Does it change if you disable optimizations on the method? Either putting a I haven't done any investigations, but my first guess would be because the two different throws are being optimized into one instruction. This happens for various reasons inside the jit and it can cause IPs that are ambiguous. I'd like to rule this easy explanation out first. |
This happens both during debugging and if I disable the optimizations using MethodImpl. I don't know if this is relevant, but this seems to happen with plain c# as well (no profiling): This code:
Produces this result: |
I think hit the same issue but different with NitzanEgozy's, which I can get different(but wrong) IL/Native offset with Expection. public static ushort[] FromPMulti2(params string[] ps)
{
if (ps.Length == 0)
#line 1000
throw new InvalidDataException("Invalid Data");
#line 2000
Console.WriteLine("XX");
#line 3000
int j = 1 / (ps.Length - 1);
if (ps.Length > 1)
#line 4000
throw new InvalidDataException("Test");
return new ushort[0];
}
static void Main(string[] args)
{
TryLog(() => FromPMulti2());
TryLog(() => FromPMulti2(""));
TryLog(() => FromPMulti2("", ""));
}
static void TryLog(Action action)
{
try
{
action();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
} Tested with @davmason |
Any news regarding this? |
Should this bug also be tagged in |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
I'm currently writing a CLR profiler, and I came across something very odd. When throwing two different exceptions, one from the try clause and one from the catch clause, the CLR notifies me of the same instruction pointer.
I'm registered to receive the ExceptionThrown callback
While inside that callback, I start a DoStackSnapshot on the current thread.
HRESULT stackSnapshotCallback(FunctionID funcId, UINT_PTR ip, COR_PRF_FRAME_INFO, ULONG32, BYTE context[], void *clientData)
(https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/profiling/icorprofilerinfo2-dostacksnapshot-method)
I have an exception thrown from a try clause and the corresponding catch clause. StackSnapshotCallback returns the SAME ip for both (UINT_PTR ip)
c# code that reproduces the issue
I'll also mention that this is not a case of a rethrow, when this is expected.
The text was updated successfully, but these errors were encountered: