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

Crash when computed help text larger than maximum length #277

Closed
Chadehoc opened this issue Apr 20, 2018 · 2 comments
Closed

Crash when computed help text larger than maximum length #277

Chadehoc opened this issue Apr 20, 2018 · 2 comments

Comments

@Chadehoc
Copy link

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.

@Oddley
Copy link

Oddley commented Apr 23, 2018

I was also seeing ArgumentOutOfRangeException related to MaximumDisplayWidth. It seems that old versions of mono for non-Windows systems would throw when Console.Width is called, but for newer versions of Mono this is not the case. See #279

@moh-hassan
Copy link
Collaborator

Fixed in V2.7+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants