show_tty as implemented could cause infinite loops #13

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

L2G commented Jan 20, 2012

I was running into situations where ProgressBar would work correctly most of the time, but then fall into an infinite loop. And I think I've tracked it down to the recursive implementation of #show_tty.

While I know that show_tty is trying to make the bar fit the width of the screen, I'll be honest--that code is too tangled for me to figure out what thinking went into it. But I do know that when I did a pen-and-paper trace through it, I could see an infinite loop happening if width, line.width, and @terminal_width started out being the same value.

So I edited it into a standard loop using break and next instead, and I gave it a limited number of iterations (10, a completely arbitrary value). I ran the test and it still seems to work, except I saw a new blank line in there that concerns me. Still, I'd rather have that than an infinite loop grinding my work to a halt any day. :-)

Owner

jfelchner commented Jul 28, 2012

@L2G, thanks for this but I think I'm going to hold off on it till v1.0 is released. I'm antsy about this big of a change with no tests. Once I get that pushed to the development branch, could you take a look and see if the same problem exists?

Owner

jfelchner commented Jul 29, 2012

Ok, development has been pushed. Feel free to take a look if you'd like. If you do, I'd appreciate any feedback you may have.

Contributor

L2G commented Jul 30, 2012

Sorry for the delayed reply. I will try to take a look at this tonight or tomorrow night.

Owner

jfelchner commented Aug 18, 2012

@L2G, I'm going to close this for now. If you get a chance to reimplement another TTY solution, I'd love a pull request. Thanks!

jfelchner closed this Aug 18, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment