-
Notifications
You must be signed in to change notification settings - Fork 48
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
[1.6.1] Chart output corrupts after a few minutes on macOS? #166
Comments
Hi @quinncomendant, thanks for the report! I do not have access to macOS outside of CI personally, running your command for 5 minutes (with multiple re-scales) on Linux does not show anything off for me. Is there a chance that you could:
|
Hi @hartwork! Thanks for the quick reply with suggestions. Yeah, if your internet is stable, ping may not reveal the issue. In order to reproduce this, you need to generate values that:
Here's a test case you can use to reproduce the issue:
for i in 13.669 13.669 13.669 17.235 17.235 17.235 17.235 17.235 17.235 17.235 10.831 10.831 10.831 10.831 10.831 10.831 93.902 93.902 93.902 93.902 93.902 93.902 93.902 93.902 2.984 2.984 2.984 2.984 2.984 2.984 2.984 6.528 6.528 6.528 6.528 6.528 6.528 6.528 6.528 5.143 5.143 5.143 5.143 5.143 5.143 5.143 5.143 8.741 8.741 8.741 8.741 8.741 8.741 8.741 8.741 2.310 2.310 2.310 2.310 2.310 2.310 2.310 10.943 10.943 10.943 10.943 10.943 10.943 10.943 10.943 18.117 18.117 18.117 18.117 18.117 18.117 18.117 18.117 11.670 11.670 11.670 11.670 11.670 11.670 11.670 11.670 5.296 5.296 5.296 5.296 5.296 5.296 5.296 5.296 8.840 8.840 8.840 8.840 8.840 8.840 8.840 8.840 7.446 7.446 7.446 7.446 7.446 7.446 7.446 7.446 7.446 6.027 6.027 6.027 6.027 6.027 6.027 6.027 6.027 4.598 4.598 4.598 4.598 4.598 4.598 4.598 4.598 4.598 8.156 8.156 8.156 8.156 8.156 8.156 8.156 8.156 8.156 6.724 6.724 6.724 6.724 6.724 6.724 6.724 6.724 5.336 5.336 5.336 5.336 5.336 5.336 5.336 5.336 5.336 8.920 8.920 8.920 8.920 8.920 8.920 8.920 8.920 2.485 2.485 2.485 2.485 2.485 2.485 2.485 2.485 2.485 6.056 6.056 6.056 6.056 6.056 6.056 6.056 6.056 3.284 3.284 3.284 3.284 3.284 3.284 3.284 3.284 6.840 6.840 6.840 6.840 6.840 6.840 6.840 6.840 6.840 5.382 5.382 5.382 5.382 5.382 5.382 5.382 5.382 3.986 3.986 3.986 3.986 3.986 3.986 3.986 3.986 3.986 2.608 2.608 2.608 2.608 2.608 2.608 2.608 2.608 1.134 1.134 1.134 1.134 1.134 1.134 1.134 1.134 1.134 4.777 4.777 4.777 4.777 4.777 4.777 4.777 4.777 3.337 3.337 3.337 3.337 3.337 3.337 3.337 3.337 3.337 6.924 6.924 6.924 6.924 6.924 6.924 6.924 6.924 50.511 50.511 50.511 50.511 50.511 50.511 50.511 50.511 50.511 4.095 4.095 4.095 4.095 4.095 4.095 4.095 4.095 2.677 2.677 2.677 2.677 2.677 2.677 2.677 2.677 2.677 1.278 1.278 1.278 1.278 1.278 1.278 1.278 1.278 3.443 3.443 3.443 3.443 3.443 3.443 3.443 3.443 3.443 7.014 7.014 7.014 7.014 7.014 7.014 7.014 7.014 5.616 5.616 5.616 5.616 5.616 5.616 5.616 5.616 5.616 7.731 7.731 7.731 7.731 7.731 7.731 7.731 7.731 7.731 6.371 6.371 6.371 6.371 6.371 6.371 6.371 6.371 4.914 4.914 4.914 4.914 4.914 4.914 4.914 4.914 4.914 3.492 3.492 3.492 3.492 3.492 3.492 3.492 3.492 2.086 2.086 2.086 2.086 2.086 2.086 2.086 2.086 2.086 0.660 0.660 0.660 0.660 0.660 0.660 0.660 0.660 4.234 4.234 4.234 4.234 4.234 4.234 4.234 4.234 4.234 2.853 2.853 2.853 2.853 2.853 2.853 2.853 2.853 2.853 1.382 1.382 1.382 1.382 1.382 1.382 1.382 1.382 0.047 0.047 0.047 0.047 0.047 0.047 0.047 0.047 0.047 8.607 8.607 8.607 8.607 8.607 8.607 8.607 8.607 2.206 2.206 2.206 2.206 2.206 2.206 2.206 2.206 2.206 5.747 5.747 5.747 5.747 5.747 5.747 5.747 5.747 7.980 7.980 7.980 7.980 7.980 7.980 7.980 7.980 6.509 6.509 6.509 6.509 6.509 6.509 6.509 6.509 6.509 5.088 5.088 5.088 5.088 5.088 5.088 5.088 5.088 5.088 3.682 3.682 3.682 3.682 3.682 3.682 3.682 3.682 2.264 2.264 2.264 2.264 2.264 2.264 2.264 2.264 2.264 5.868 5.868 5.868 5.868 5.868 5.868 5.868 5.868 4.424 4.424 4.424 4.424 4.424 4.424 4.424 4.424 4.424 7.988 7.988 7.988 7.988 7.988 7.988 7.988 7.988 6.607 6.607 6.607 6.607 6.607 6.607 6.607 6.607 6.607 5.181 5.181 5.181 5.181 5.181 5.181 5.181 5.181 8.746 8.746 8.746 8.746 8.746 8.746 8.746 8.746 8.746; do echo $i; sleep 0.1; done | ttyplot This prints a value to the screen every 1/10 seconds. After about 12 seconds, the screen will look like this: |
Hi @quinncomendant, thanks for the update! Neither after 12 seconds nor anywhere between start and finish anything like that appears for me with 1.6.1 on (Gentoo) Linux, my terminal was exactly 90x20 in Terminator. Could you try with Linux or from source or on different (macOS) hardware? |
@quinncomendant update: no corruptions like that with 90x20 in Terminator on Debian bookworm with ttyplot 1.6.1 built from source, either. |
Hi @quinncomendant, and thanks for the report. I couldn't reproduce the issue either. I am using:
|
I did more experiments. The issue only occurs on macOS, when using iTerm version
I know terminal emulation can be difficult to troubleshoot because of all the variables on multiple layers. I would be happy to just blame iTerm because it's a huge ball of wax. However, the fact that ttyplot v1.5.2 works, and v1.6.1 does not, in identical environments, is evidence that something changed that made ttyplot less resilient to working well in obscure environments, namely, mine. Here's a screen recording showing v1.5.2 and v1.6.1 running side-by-side. |
@quinncomendant thanks a lot for investigating further and sharing your findings and the recording! My personal key takeway from what you shared is that the combination of local operation + iTerm2 + ttyplot 1.6.1 is the problem. (I'm assuming here that you already are running the latest version 3.4.23 of iTerm2 so that we're not dealing with already fixed bugs in iTerm, either something novel or outside of iTerm2?) To me it sounds like the local NCurses layer could be involved (because with SSH part of NCurses is no longer local). There were two bigger pull requests between 1.5.1 and 1.6.0 that changed things in the NCurses area:
What I am guessing right now is the symptom would go away adding (or re-adding) "full-screen" redrawing somewhere. I'm ignoring the question here whether ttyplot or iTerm would be at fault then then but that's at least an area where things changed and where we could experiment to see if it makes the symptoms go away. The pull requests are not small and not trivial but maybe you'd still see something that stands out to you as a candidate for the source of that problem. Could you have a quick look at the two and see if something catches your intention for a potential cause or for something with potential for experimentation? |
@quinncomendant: Some random ideas...
|
I tested this again on an older MacBook which I recently reinstalled the OS, so it has a virgin terminal environment (never used, never customized). I installed iTerm and ttyplot for the first time. The issue occurs there! Also, I discovered it only occurs with the beta version of iTerm (3.5.0beta18), and not the stable release (3.4.23). The beta version of iTerm is far ahead of the stable release, so I've been using it everywhere. I think the iTerm team even recommends it. Searching the changelog of the beta releases I can see many dozens of fixes related to drawing text and screen management, so it's no surprise that there is a difference. @hartwork, I checked those two pull requests and briefly scanned the commits, but I'm not familiar enough with ttyplot's design to know which might be more the cause. If I had to guess on a hunch, it seems like c150198 has the most changes related to screen redraw, so we could start there? If there any way I can get a copy of the source code before these pull requests and merge them myself? (I'm not very familiar with GitHub.) @edgar-bonet, I can do the random ideas you suggested, but I think it may not be useful since I already discovered ttyplot 1.6.1 does work fine locally on macOS when using the default Terminal.app or the stable version of iTerm, it only occurs with the beta version of iTerm. It's not environmental differences that cause the issue. |
The Web UI way:
The git way: git clone https://github.com/tenox7/ttyplot.git
cd ttyplot
git checkout c150198^ # the “^” suffix means “parent of” Note that git can be very helpful for bisecting the history and get the exact commit that broke something: git bisect start
git bisect good 1.5.2
git bisect bad 1.6.1 At this point git checks out an intermediate revision and asks you to test it. You reply by typing either
That's not certain. Ttyplot relies on ncurses, and ncurses uses the |
@edgar-bonet suggesting @quinncomendant one thing I'm wondering is if 1.5.2 works for you and 1.6.1 how did you install each and where do they get ther (N)Curses from — from Homebrew or from stock macOS? Both of these versions? I see potential for more insights and variance there, maybe it can be pinned down further. To re-summarize, so far we have that it needs all of:
So (1) from source and/or homebrew and (2) the precise source and version of (N)Curses could give additional insights. |
@edgar-bonet Thanks for the tip to use
I manually checkout’ed a series of commits in this range and tested them one-by-one, with the following results (in order from newest commits to older):
This is confirms what git bisect already said, that the bug was introduced in c73270c or 61c2cf5.
Throughout my testing, @hartwork As far as I can tell there is only one ncurses installed: the one included with the macOS developer tools. According to
|
Hi @quinncomendant, thanks for investigating more and sharing your findings with us! If we're looking at some flavor of memory corruption, maybe compiling with AddressSanitizer and UndefinedBehaviorSanitizer and running again could lead to insights: env {C,LD}FLAGS=-fsanitize=address,undefined make clean all
[..data piping here..] | MallocNanoZone=0 ./ttyplot [..arguments here..] If it now crashes at runtime, that would be a first clue. @edgar-bonet any ideas what in c73270c it could possible be (if anything)? I remember because of the global |
@quinncomendant: Thanks for bisecting this! It is really useful. Commit 61c2cf5 is only about getting the I did a small test to capture the output of ttyplot: script -c 'seq 1 10 | ./ttyplot' and compared c73270c with its parent. The most striking difference is that the output was initially ASCII-only, with lines made out of DEC Special Graphics, which got replaced by UTF-8-encoded Box-drawing characters. For example, the sequence
where the However, since the vertical lines are initially rendered correctly, this difference in output does not explain the problem.
You may run infocmp xterm-256color on both your Mac and the Ubuntu server, and compare the outputs. @hartwork wrote:
We have seen that the ASCII-only and the wide-character-capable APIs are declared in the same header file... or in different header files, depending on the OS. There seems to be quite a bit of variability in how ncurses is deployed. Since the wide-character-capable API is a superset of the older one, I am not that much surprised that a system could provide only one dynamic library with the most complete API. |
Building and running it like that changed nothing. |
Ah yes, this is interesting. Another possible clue: the issue can be reproduced simply by resizing the window, but only after the corruption occurs while when rendering the plot. Corruption only occurs if the set of values is widely variable such that the chart needs to rescale after some very large numbers scroll off the screen. If a plot is rendered with consistent values (so the plot never needs to rescale), the screen never corrupts, and then the issue does not present itself by resizing the window. But once the corruption has occurred, even very briefly, resizing the window will consistently cause display issues. So, the UTF box-drawing characters might not be to blame (since their presence does not, on its own, cause the corruption), but perhaps only in relation to the chart rescale algorithm.
Oh, wow, more dark secrets of the terminal. 🙃 Indeed, there is a difference between Terminal.app and iTerm stable, and iTerm beta: Terminal.app and iTerm stable (no corruption)
iTerm beta (corruption occurs)
|
@quinncomendant: Interesting! You have two terminal description files named xterm-256color:
These files are different: some escape sequences differ, and the second file declares some terminal capabilities that are not in the first one. It would be interesting to see whether the problem is related to those differences. In iTerm beta, there must be some environment variable providing a non-standard search path for the terminfo database. You may look for env | grep terminfo Could you try to unset this variable in order to run iTerm beta with the standard, system-provided, terminfo database? You may also set the variable in iTerm stable in order to run it with the database from iTerm beta. This should tell us whether the issue is related to this terminal description. |
@edgar-bonet Indeed, the iTerm beta terminfo is set via a custom So, it seems like we're narrowing down the necessary conditions to: ttyplot at commit c73270c + iTerm beta terminfo file (which is on GitHub, if you'd like to test this presumption on your computer). |
@quinncomendant: I ran your test ( I am using:
Although I cannot assert it's iTerm's fault (or its terminfo file), I would suggest you file an issue on their bug tracker. iTerm's developers have probably much more expertise on terminal description files than anyone here. It would be nice to know whether that gets fixed on their side. |
I had already done so. |
I recently upgraded ttyplot on macOS from
1.5.2
to1.6.1
(viabrew upgrade
), and the new version displays some misplaced character artifacts in the chart after a few minutes of running. I use this command:I've run the first part of the command simutaneously in a separate window to view the input data to ensure it is not causing ttyplot to become corrupted, and it does not: each line contains just one numeric value.
The chart starts out displaying correctly:
But after a few minutes, once the variation in values changes enough for ttyplot to rescale the chart, it can look like this:
Since this was not happening with ttyplot version
1.5.2
, it must be something with the new version (which has a new plotting algorithm?).The text was updated successfully, but these errors were encountered: