dotnet / dotnet/command-line-api

Exception stack-traces when using System.CommandLine.DragonFruit are not friendly...

Offen
#668 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
waiting-on-feedback
Vorherrschende Sprache
C#
Sterne
3.7k
Forks
428
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Here's a sample assertion from a program I have using System.CommandLine.DragonFruit:

Note:
1. I tried to catch the exception and Just print nothing instead of this wall of text (below):
```csharp
public static unsafe void Main(...)
{
try {
WrappedMain(...);
}
catch {
Console.WriteLine("XXX");
}
}
```
This does not work, I didn't bother to investigate why that is the case
2. Instead, the default behaviour here generated 90 lines of exception stack trace,
**84** (!) of which are internal stuff inside System.CommandLine.DragonFruit which I would claim that no normal user should care about? Wouldn't it make sense to never have this printed under any circumstances to the user, except for maybe debug builds of your own package?
```bash
Process terminated. Assertion failed.
depth=0 boundary=30, idx = 0 *t(24) <= pivot=12
at QuickSortAvaganza.AVX2.Happy.AVX2DoublePumpedAlignedOverlapUnrolledWithPCSort`1.QuickSortInt32.VerifyBoundaryIsCorrect(Int32* left, Int32* right, Int32 pivot, Int32* boundary) in /home/dmg/projects/public/QuicksortAvaganza/QuickSortAvaganza/AVX2/Happy/07_AVX2DoublePumpedUnrolledWithPCSort.cs:line 809
at QuickSortAvaganza.AVX2.Happy.AVX2DoublePumpedAlignedOverlapUnrolledWithPCSort`1.QuickSortInt32.VectorizedPartitionInPlace(Int32* left, Int32* right, Int64 hint) in /home/dmg/projects/public/QuicksortAvaganza/QuickSortAvaganza/AVX2/Happy/07_AVX2DoublePumpedUnrolledWithPCSort.cs:line 491
at QuickSortAvaganza.AVX2.Happy.AVX2DoublePumpedAlignedOverlapUnrolledWithPCSort`1.QuickSortInt32.QuickSort(Int32* left, Int32* right, Int64 hint) in /home/dmg/projects/public/QuicksortAvaganza/QuickSortAvaganza/AVX2/Happy/07_AVX2DoublePumpedUnrolledWithPCSort.cs:line 208
at QuickSortAvaganza.AVX2.Happy.AVX2DoublePumpedAlignedOverlapUnrolledWithPCSort`1.QuickSort(T[] array) in /home/dmg/projects/public/QuicksortAvaganza/QuickSortAvaganza/AVX2/Happy/07_AVX2DoublePumpedUnrolledWithPCSort.cs:line 27
at Example.Program.WrappedMain(String typeList, String sizeList, Int32 maxLoops, Int32 modulo, Int32 forceValue, Double forceRate, Boolean noCheck, String statsFile) in /home/dmg/projects/public/QuicksortAvaganza/Example/Program.cs:line 93
at Example.Program.Main(String typeList, String sizeList, Int32 maxLoops, Int32 modulo, Int32 forceValue, Double forceRate, Boolean noCheck, String statsFile) in /home/dmg/projects/public/QuicksortAvaganza/Example/Program.cs:line 49
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.b__0(InvocationContext invocationContext, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass1_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass1_0.b__0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__22_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__22_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass8_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass8_0.b__0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__7_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__7_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__6_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__6_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__20_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__20_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass3_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass3_0.b__0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__23_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__23_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass5_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass5_0.b__0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__4_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__4_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__0_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__0_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(IConsole console)
at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, ParseResult parseResult, IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, ParseResult parseResult, IConsole console)
at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, String[] args, IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, String[] args, IConsole console)
at System.CommandLine.DragonFruit.CommandLine.InvokeMethodAsync(String[] args, MethodInfo method, String xmlDocsFilePath, Object target, IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.DragonFruit.CommandLine.InvokeMethodAsync(String[] args, MethodInfo method, String xmlDocsFilePath, Object target, IConsole console)
at System.CommandLine.DragonFruit.CommandLine.ExecuteAssemblyAsync(Assembly entryAssembly, String[] args, String entryPointFullTypeName, String xmlDocsFilePath, IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.DragonFruit.CommandLine.ExecuteAssemblyAsync(Assembly entryAssembly, String[] args, String entryPointFullTypeName, String xmlDocsFilePath, IConsole console)
at AutoGeneratedProgram.Main(String[] args) in /home/dmg/projects/public/QuicksortAvaganza/Example/obj/Debug/netcoreapp3.0/Example.Program.g.cs:line 10
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at AutoGeneratedProgram.Main(String[] args)
at AutoGeneratedProgram.(String[] args)
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, den Assertion-Fehler über System.CommandLine.DragonFruit zu reproduzieren, und verfolge den Pfad durch CommandLine.InvokeMethodAsync und ExecuteAssemblyAsync. Überprüfe, wie die Aufrufpipeline Ausnahmen behandelt, und ermittle die vorgesehene benutzerseitige Ausgabe; als erledigt gilt die Aufgabe, wenn normale Benutzer nicht mehr den langen internen Stacktrace erhalten, der Fehler aber weiterhin diagnostizierbar bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.