Conversation
|
Tagging subscribers to this area: @agocke |
227f207 to
df453ad
Compare
|
@EgorBot -osx_arm64 using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkSwitcher
.FromAssembly(typeof(ExceptionBench).Assembly)
.Run(args);
[MemoryDiagnoser]
[SimpleJob(warmupCount: 3, iterationCount: 10)]
public class ExceptionBench
{
private static volatile int _sink;
[Benchmark]
public void ThrowCatch()
{
try
{
Thrower();
}
catch (InvalidOperationException ex)
{
_sink = ex.HResult;
}
}
private static void Thrower()
{
throw new InvalidOperationException("boom");
}
[Benchmark]
public void NullRefThrow()
{
try
{
object o = null!;
_ = o.ToString(); // NullRef
}
catch
{
}
}
[Benchmark]
public void Rethrow()
{
try
{
try
{
Thrower();
}
catch
{
throw;
}
}
catch
{
}
}
} |
src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
Outdated
Show resolved
Hide resolved
| return default; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
I would split Start and Finalizer into a separate PR to make this easier to land.
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs
Outdated
Show resolved
Hide resolved
|
|
||
| uint32_t count; | ||
| CALL_MANAGED_METHOD(count, uint32_t, args); | ||
| UnmanagedCallersOnlyCaller runFinalizers(METHOD__GC__RUN_FINALIZERS); |
There was a problem hiding this comment.
This one and Thread.Start have concerns about unhandled exception post-mortem diagnostics, similar to the concerns we had with Main method. We need to make sure that the unhandled exceptions produce crash dump with the original stack preserved for good post-mortem diagnostics, on both Windows and Unix. It does not seem to be the case by just looking at the code.
(Unlike the Main method, we do not need to hide the extra frames from stacktraces in these cases.)
There was a problem hiding this comment.
Updated accordingly (without conditioning stacktrace). I am waiting for the CI run to understand if we need to further fine-tune it.
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs
Show resolved
Hide resolved
| object exceptionObj = *pExceptionObj; | ||
| RhThrowEx(exceptionObj, ref *pExInfo); | ||
| } | ||
| catch (Exception ex) |
There was a problem hiding this comment.
These changes in the ExceptionHandling.cs are not needed. Managed exception is never propagated out of the RhThrowEx et al.
2d3d910 to
ff25723
Compare
Contributes to prio3 from #123864