Yes, it's always the first character on a line, and always the diamond question mark. It seems like the fuller the buffer gets (I run iterm for days, multiple tabs, 1million lines per tab) the more often it happens.
The next time this happens, turn on Prefs > Advanced > Show line buffer block boundaries (issue 6207). Then click in the iTerm2 window and let me know if the line with the diamond question mark turns into a row of Xes.
If this occurs, it confirms the issue happens with the first character of a LineBlock. That's the only lead I have to go on so far, but it would help to narrow the field of possibilities a bit.
I had it happen again today, and turned on the 6207 function. It did not change the output:
[cid:image001.png@01D36CFC.59EFC300]
Also note that it seems to have removed the first two characters of the line above it. I know it did work, because other lines did turn into lines of X's.
I'm using Build 3.1.20171130-nightly, if that's the right version.
That's the unicode replacement character. That's really interesting because there are only a few places in the app where we would produce those, and it's all in input handling. Either we're getting a replacement character as input or there is memory corruption that just happens to plop a replacement character in history. Please try this build, which will log a critical error any time a replacement character is touched. When you run it and the problem occurs, it may show a dialog telling you it made a debug log. If it does, send me the debug log. If you still get the replacement character but no dialog box saying there was a critical error, let me know—that's interesting too.
Thanks for the build. I ran it, and almost right away got the dialog about the debug output. But when I went back through the buffer I didn't see anything. It may be because of the session it restored.
It hasn't done it again yet, but sometimes it takes a while. I will send another one if it happens again.
I just had this happen again. It happened when I tried to launch vi.
When I went back in the buffer after that, I could see the corruption:
[cid:image001.png@01D38BAC.C460F280]
and
[cid:image002.png@01D38BAC.C460F280]
I went into another tab and went into vi there, but did not get the pop-up. But when I rolled back in the buffer there was corruption.
I was able to reproduce this a few times.
My terminal is set to xterm-256color. I am using vim in vi compatibility mode:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 30 2016 20:54:06)
Included patches: 1-52
When I start vi, it does this stuff:
^[[?1049h^[[?1h^[=^[[1;45r^[[?12;25h^[[?12l^[[?25h^[[27m^[[m^[[H^[[2J^[[?25l^[[2;1H^[[94m~... a bunch of ^[[16;1H~ with different values^[[m^[[45;183H0,0-1^[[9CAll^[[1;1H^[[?12l^[[?25h^[[?25l^[[45;1H^[[K^[[45;1H:q!^M^[[45;1H^[[K^[[45;1H^[[?1l^[>^[[?12l^[[?25h^[[?1049l
I was also able to reproduce the issue with my terminal set to vt220. When I have that, vi does:
Hey, sorry for the delay in getting back to you. I've been super backlogged this week.
It looks like vim is sending some malformed UTF-8. Unfortunately the debug log does not capture such codes (I thought it did, sorry!). At any rate, it should be simple enough to track down its cause. I expect it's probably a vim extension, so try going back to a default vim setup and see if it goes away, then add things back slowly until the issue recurs.
To verify that it's actually bogus UTF-8 (vs a bug in iTerm2 that misidentifies correct UTF-8 as malformed), you can create a log of the session by following these steps:
Select the menu item Session > Log > Start
Reproduce the problem
Select the menu item Session > Log > Stop
Validate the UTF-8 with iconv -f UTF-8 logfile.txt > /dev/null && echo ok || echo fail
So far it sounds like it's not corruption, but just occasional bogus UTF-8 inputs. Let me know if you can find an instance where that's not the case and I'll be glad to look into it some more. That special build (here) is useful for testing the hypothesis since it'll give you a critical error on such input.