Skip to content

Crash when computed help text larger than maximum length #277

Closed
@Chadehoc

Description

@Chadehoc

Maximum length for displaying help is 120 in Parser.Default. If a long help text makes the computed length larger than that (when reporting a parsing error), an ArgumentOutOfRangeException is raised.

Details:

In HelpText.AddOptionsImpl, maxLength = GetMaxLength(specifications) is large enough so that remainingSpace below becomes negative, which is passed to HelpText.AddOption as widthOfHelpText, and used there with an exception.

If I manually set the negative remainingSpace to 0 in the debugger, it goes on to an out of memory error. Setting to 1 is ok, but illogical, so there must be another hidden bug that 0 reveals.

Also, this error only occurs with Parser.Default. If I use an unmodified new Parser(s => Console.WriteLine(s.MaximumDisplayWidth)), this prints 120, the same result is returned (error list), but without crashing. So this behaviour also depends on another setting than the maximum length.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions