While resizing the terminal smaller, the following exception occurs. It's not clear exactly how to reproduce. I cat the content of a file and then resize the terminal to a small size:
Uncaught TypeError: Cannot read property '_data' of undefined
at BufferLine.copyCellsFrom (xterm.js:887)
at Buffer._reflowSmaller (xterm.js:468)
at Buffer._reflow (xterm.js:388)
at Buffer.resize (xterm.js:370)
at BufferSet.resize (xterm.js:1140)
at Terminal.resize (xterm.js:5078)
at Terminal.resize (xterm.js:6615)
at resize (kubebox.js:1351)
at Item.run (kubebox.js:52341)
at drainQueue (kubebox.js:52311)
We've been seeing this same exception frequently in cocalc recently. As a sad workaround for now, we've been wrapping calls to resize in try/catch, to at least not crash the entire user's session. I also have no idea how to reproduce this. It's relatively recent, so probably caused by something introduced in 3.11 or 3.10.
We wanted to update to version 3.11.0 in cockpit but on testing I saw this exception as well. Also not able to reproduce this constantly, it happens randomly on resizing.
Sometimes I even see these (seem different as original issue, but most likely related):
Uncaught TypeError: Cannot read property 'get' of undefined
at t._forEachCell (TextRenderLayer.js:51)
at t._drawBackground (TextRenderLayer.js:101)
at t.onGridChanged (TextRenderLayer.js:164)
at Renderer.js:166
at Array.forEach (<anonymous>)
at t._renderRows (Renderer.js:166)
at e._innerRefresh (RenderDebouncer.js:31)
at RenderDebouncer.js:26
InputHandler.js:435 Uncaught TypeError: Cannot read property 'replaceCells' of undefined
at t._eraseInBufferLine (InputHandler.js:435)
at t.eraseInLine (InputHandler.js:489)
at Array.<anonymous> (InputHandler.js:96)
at n.parse (EscapeSequenceParser.js:402)
at t.parse (InputHandler.js:191)
at t._innerWrite (Terminal.js:893)
at Terminal.js:875
I think this is a duplicate of https://github.com/xtermjs/xterm.js/issues/1926, I suspect there may still be an obscure crash still somewhere as I've had a few reports in https://github.com/Microsoft/vscode/issues/69603, but almost all cases appear to be fixed by that issue.
I've just tested with version 3.12.0 and can still reproduce the error. I'll let other people affected confirm, yet I don't think that's fixed.
If you can nail down a repro let me know as I can't repro https://github.com/Microsoft/vscode/issues/69603
If you can nail down a repro let me know as I can't repro Microsoft/vscode#69603
Yes, I'll try to have a minimal reproducer ASAP. Meanwhile, it'd be better to leave that open so other people affected may provider a reproducer too.
Hi @Tyriar,
After doing more tests, we found that this bug occurs when resizing cuts off tab symbol.
e.g. Seting cols to 8 and echo a\tb, then resizing cols to 7.
-- origin --
I found a way to reproduce this bug.
After cloning the repo and installing all dependencies, I run the demo page by yarn start.

The following c code is the program I had executed in above gif.
#include <stdio.h>
int main() {
int m, n;
for (m = 1; m <= 9; ++m) {
for (n = 1; n <= 9; ++n) {
printf("%d * %d = %2d\t", m, n, m * n);
}
printf("\n=======================\n");
}
return 0;
}
Hi @Tyriar, I haven't dived into the source code too much. So it just my guess.
After some tracing, I think this bug may cause by reflowSmallerGetNewLineLengths that is called at:
https://github.com/xtermjs/xterm.js/blob/master/src/Buffer.ts#L304
Which define at:
https://github.com/xtermjs/xterm.js/blob/master/src/BufferReflow.ts#L174
The reason is that the value return by reflowSmallerGetNewLineLengths cause linesToAdd becoming -1.
We are hitting something like that in Theia as well: https://github.com/theia-ide/theia/pull/4680#issuecomment-476090542
I can reproduce it with running top -c and resizing the terminal widget.
Reproducible in latest VS Code as well:
top -c
I have some repro steps for this in vscode at least:
Repro steps:
Same can happen using split terminals
Source: https://github.com/Microsoft/vscode/issues/71572#issuecomment-478846614
@Tyriar Hi, just wanted to check whether you plan to look into it for 3.13?
I got a better repro:
lsResize to 48 cols (optional)

Resize to 47 cols

I think what's happening is that the trimmed line is being used on all parts of a wrapped line in reflowSmallerGetNewLineLengths when it should only be used on the last line. That's why it happens above, because of the way ls formats with \t which just advances the cursor.
I have a fix out in PR https://github.com/xtermjs/xterm.js/pull/2002. If anyone gets a chance, please see if you still have issues with that branch.
I confirm #2002 fixes the issue.
Thanks @Tyriar!
I released 3.12.1 that includes just this fix https://github.com/xtermjs/xterm.js/releases/tag/3.12.1, beta for 3.13.0 coming soon so
Most helpful comment
I released 3.12.1 that includes just this fix https://github.com/xtermjs/xterm.js/releases/tag/3.12.1, beta for 3.13.0 coming soon so