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

Issue #821 - Prevent TypeError in resize() #823

Merged
merged 1 commit into from
Jul 28, 2017
Merged

Issue #821 - Prevent TypeError in resize() #823

merged 1 commit into from
Jul 28, 2017

Conversation

jpmasters
Copy link

@jpmasters jpmasters commented Jul 28, 2017

Updated Terminal resize() to fill undefined rows before resizing them.

Closes #821.

@coveralls
Copy link

coveralls commented Jul 28, 2017

Coverage Status

Coverage decreased (-0.03%) to 70.375% when pulling acdd316 on jpmasters:master into f36bd24 on sourcelair:master.

@parisk
Copy link
Contributor

parisk commented Jul 28, 2017

Thanks for this PR @jpmasters! Can you please revert the changes in all files in dist/ and squash the commits please?

Copy link
Contributor

@parisk parisk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just revert the changes in dist/ and squash commits and we are good to go 😄 .

@parisk parisk self-assigned this Jul 28, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 70.375% when pulling 2d4e617 on jpmasters:master into f36bd24 on sourcelair:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 70.375% when pulling 2d4e617 on jpmasters:master into f36bd24 on sourcelair:master.

@coveralls
Copy link

coveralls commented Jul 28, 2017

Coverage Status

Coverage decreased (-0.03%) to 70.375% when pulling 2d4e617 on jpmasters:master into f36bd24 on sourcelair:master.

@parisk
Copy link
Contributor

parisk commented Jul 28, 2017

Again, thanks for this PR @jpmasters! I was able to remove the checked out dist/* files myself, without bothering you 😄.

@parisk parisk merged commit cdcbf60 into xtermjs:master Jul 28, 2017
@parisk parisk added this to the 2.9.0 milestone Jul 28, 2017
@jpmasters
Copy link
Author

Awesome, thanks @parisk, I wasn't sure whether the /dist files needed to be updated or not. Does this mean that gulp needs to be run after xterm.js is added to a project via a bower install or is this done automatically?

@parisk
Copy link
Contributor

parisk commented Jul 28, 2017

@jpmasters the dist/* files are updated only on new releases and they are there only for Bower.

This will go away thankfully though on 3.0: #406.

@@ -1941,6 +1941,9 @@ Terminal.prototype.resize = function(x, y) {
ch = [this.defAttr, ' ', 1]; // does xterm use the default attr?
i = this.buffer.lines.length;
while (i--) {
if (this.buffer.lines.get(i) === undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resize rows section below is meant to handle this row resizing, if this is actually happening we should figure out the root cause. this.buffer.lines.get(i) should always return an array when i < this.buffer.lines.length which is guaranteed by line 1942.

Copy link
Author

@jpmasters jpmasters Jul 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Underneath the CircularList is just a straight Javascript array so I'm assuming that somehow 'undefined' got pushed into the array. Could that not give the same symptoms? I'm wondering if perhaps there was some kind of problem parsing the data from the server that resulted in an undefined object getting into the circular list.

I'll try an experiment by looking for a push of an undefined into CircularList and see if that yields any clues.

Copy link
Author

@jpmasters jpmasters Jul 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at what is happening in the debugger, we're making a lot of use of the RI escape sequence to implement a 'scrolling' area of the terminal screen. This seems to result in calls to shiftElements that in turn calls set() in the circular buffer code which is bringing undefined data from the unused 1000 circular buffer array entries into the part being used by xterm.

I think the root cause might be line 2282 in xterm.js (Terminal.prototype.reverseIndex).

    this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, this.rows - 1, 1);

When I look at the prototype for shiftElements the parameters are start, count and offset so instead of setting count to this.rows - 1 should it not also subtract (this.buffer.y + this.buffer.ybase)? Otherwise when this.set is called in shiftElements (line 174 in CirlculstList.ts), it could be bringing in undefined data from the unused array area in the circular list buffer.

Edit: Using this patch I was able to fix the problem but this was only with a ybase of 0. Not sure what happens when ybase !== 0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice investigation 😄 could you come up with a script or something that can reproduce the problem and put into #824? The best way I've found to do these is to open devtools console in the demo and type term.write('\x1b[blah...') containing the escape sequences that cause the issue.

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

Successfully merging this pull request may close these issues.

4 participants